Skip to content

Commit

Permalink
o
Browse files Browse the repository at this point in the history
[13.0][ADD] stock_quant_editable_view_block
  • Loading branch information
HviorForgeFlow committed Jul 30, 2020
1 parent e4021e5 commit 95d093c
Show file tree
Hide file tree
Showing 14 changed files with 715 additions and 0 deletions.
6 changes: 6 additions & 0 deletions setup/stock_quant_editable_view_block/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
76 changes: 76 additions & 0 deletions stock_quant_editable_view_block/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
===============================
Stock Quant editable View block
===============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_quant_editable_view_block
:alt: OCA/stock-logistics-warehouse
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_quant_editable_view_block
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/153/13.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module block the ability to update Inventory quantities using Stock Quant Model.

Furthermore, clicking on Update Quantity button from Product Card will propose
you to create a predefined Inventory Adjustment for selected product.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_quant_editable_view_block%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* ForgeFlow

Contributors
~~~~~~~~~~~~

* Héctor Villarreal <hector.villarreal@forgeflow.com>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_quant_editable_view_block>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions stock_quant_editable_view_block/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions stock_quant_editable_view_block/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# © 2016-2020 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
"name": "Stock Quant editable View block",
"version": "13.0.1.0.0",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-warehouse",
"category": "Warehouse",
"depends": ["stock"],
"license": "AGPL-3",
"data": ["views/product_views.xml"],
"installable": True,
"application": False,
}
2 changes: 2 additions & 0 deletions stock_quant_editable_view_block/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import product
from . import stock_quant
47 changes: 47 additions & 0 deletions stock_quant_editable_view_block/models/product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2018-20 ForgeFlow <http://www.forgeflow.com>

from odoo import _, models


class ProductTemplate(models.Model):
_inherit = "product.template"

def action_update_quantity_on_inventory_adjustment(self):
""" Create an Inventory Adjustment instead of edit directly on quants
"""
self.ensure_one()
view_form_id = self.env.ref("stock.view_inventory_form").id
action = self.env.ref("stock.action_inventory_form").read()[0]
action.update(
{
"views": [(view_form_id, "form")],
"view_mode": "form",
"context": {
"default_product_ids": [(6, 0, self.product_variant_ids.ids)],
"default_name": _("%s: Inventory Adjustment" % self.display_name),
},
}
)
return action


class ProductProduct(models.Model):
_inherit = "product.product"

def action_update_quantity_on_inventory_adjustment(self):
""" Create an Inventory Adjustment instead of edit directly on quants
"""
self.ensure_one()
view_form_id = self.env.ref("stock.view_inventory_form").id
action = self.env.ref("stock.action_inventory_form").read()[0]
action.update(
{
"views": [(view_form_id, "form")],
"view_mode": "form",
"context": {
"default_product_ids": [(6, 0, [self.id])],
"default_name": _("%s: Inventory Adjustment" % self.display_name),
},
}
)
return action
23 changes: 23 additions & 0 deletions stock_quant_editable_view_block/models/stock_quant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2018-20 ForgeFlow <http://www.forgeflow.com>

from odoo import api, models


class StockQuant(models.Model):
_inherit = "stock.quant"

@api.model
def _get_quants_action(self, domain=None, extend=False):
action = super()._get_quants_action(domain=domain, extend=extend)
action["view_id"] = self.env.ref("stock.view_stock_quant_tree").id
# Enables form view in readonly list
action.update(
{
"view_mode": "tree,form",
"views": [
(action["view_id"], "list"),
(self.env.ref("stock.view_stock_quant_form").id, "form"),
],
}
)
return action
1 change: 1 addition & 0 deletions stock_quant_editable_view_block/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Héctor Villarreal <hector.villarreal@forgeflow.com>
4 changes: 4 additions & 0 deletions stock_quant_editable_view_block/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module block the ability to update Inventory quantities using Stock Quant Model.

Furthermore, clicking on Update Quantity button from Product Card will propose
you to create a predefined Inventory Adjustment for selected product.
Loading

0 comments on commit 95d093c

Please sign in to comment.