Skip to content

Commit

Permalink
Merge PR #846 into 13.0
Browse files Browse the repository at this point in the history
Signed-off-by LoisRForgeFlow
  • Loading branch information
OCA-git-bot committed Sep 23, 2020
2 parents a740dd6 + fe3e246 commit 08156b4
Show file tree
Hide file tree
Showing 14 changed files with 726 additions and 0 deletions.
80 changes: 80 additions & 0 deletions product_quantity_update_force_inventory/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
=======================================
Product Quantity Update Force Inventory
=======================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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/product_quantity_update_force_inventory
: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-product_quantity_update_force_inventory
: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|

With this module, when a user goes to a product and presses the button 'Update Quantity' they will be directed to a new
Inventory Adjustment for this product, instead of driving the user to update the quantities in the
stock quants.

By doing this users will be able to have full traceability on the inventory adjustment activities.

Consider using this module together with the module 'stock_change_qty_reason'
(https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_change_qty_reason).

**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:%20product_quantity_update_force_inventory%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/product_quantity_update_force_inventory>`_ 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 product_quantity_update_force_inventory/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions product_quantity_update_force_inventory/__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": "Product Quantity Update Force Inventory",
"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 product_quantity_update_force_inventory/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 product_quantity_update_force_inventory/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 product_quantity_update_force_inventory/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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Héctor Villarreal <hector.villarreal@forgeflow.com>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
With this module, when a user goes to a product and presses the button 'Update Quantity' they will be directed to a new
Inventory Adjustment for this product, instead of driving the user to update the quantities in the
stock quants.

By doing this users will be able to have full traceability on the inventory adjustment activities.

Consider using this module together with the module 'stock_change_qty_reason'
(https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_change_qty_reason).
Loading

0 comments on commit 08156b4

Please sign in to comment.