diff --git a/stock_orderpoint_move_link/README.rst b/stock_orderpoint_move_link/README.rst new file mode 100644 index 000000000..95bd09558 --- /dev/null +++ b/stock_orderpoint_move_link/README.rst @@ -0,0 +1,51 @@ +.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg + :target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 + +============================== +Stock Orderpoint Move Link +============================== + +This module adds to stock moves a direct link to the reordering rules +that created them. In chained moves, the reordering rule is propagated. + + +Usage +===== + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/153/11.0 + + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of +trouble, please check there if your issue has already been reported. If you +spotted it first, help us smash it by providing detailed and welcomed feedback. + + +Credits +======= + +Contributors +------------ + +* Jordi Ballester + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +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. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/stock_orderpoint_move_link/__init__.py b/stock_orderpoint_move_link/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/stock_orderpoint_move_link/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_orderpoint_move_link/__manifest__.py b/stock_orderpoint_move_link/__manifest__.py new file mode 100644 index 000000000..1b7ee7514 --- /dev/null +++ b/stock_orderpoint_move_link/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2017 Eficent Business and IT Consulting Services, S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +{ + "name": "Stock Orderpoint Move Link", + "summary": "Link Reordering rules to stock moves", + "version": "11.0.1.0.0", + "license": "LGPL-3", + "website": "https://github.com/stock-logistics-warehouse", + "author": "Eficent, " + "Odoo Community Association (OCA)", + "category": "Warehouse Management", + "depends": [ + "stock", + ], + "data": [ + "views/stock_move_views.xml", + ], + "installable": True, + 'auto_install': True, +} diff --git a/stock_orderpoint_move_link/models/__init__.py b/stock_orderpoint_move_link/models/__init__.py new file mode 100644 index 000000000..0d85051fe --- /dev/null +++ b/stock_orderpoint_move_link/models/__init__.py @@ -0,0 +1,2 @@ +from . import procurement_rule +from . import stock_move diff --git a/stock_orderpoint_move_link/models/procurement_rule.py b/stock_orderpoint_move_link/models/procurement_rule.py new file mode 100644 index 000000000..0b5390e85 --- /dev/null +++ b/stock_orderpoint_move_link/models/procurement_rule.py @@ -0,0 +1,20 @@ +# Copyright 2017 Eficent Business and IT Consulting Services, S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo import models + + +class ProcurementRule(models.Model): + _inherit = 'procurement.rule' + + def _get_stock_move_values(self, product_id, product_qty, product_uom, + location_id, name, origin, values, group_id): + vals = super(ProcurementRule, self)._get_stock_move_values( + product_id, product_qty, product_uom, + location_id, name, origin, values, group_id) + if 'orderpoint_id' in values: + vals['orderpoint_ids'] = [(4, values['orderpoint_id'].id)] + elif 'orderpoint_ids' in values: + vals['orderpoint_ids'] = [(4, o.id) + for o in vals['orderpoint_ids']] + return vals diff --git a/stock_orderpoint_move_link/models/stock_move.py b/stock_orderpoint_move_link/models/stock_move.py new file mode 100644 index 000000000..56200d9c3 --- /dev/null +++ b/stock_orderpoint_move_link/models/stock_move.py @@ -0,0 +1,25 @@ +# Copyright 2018 Eficent Business and IT Consulting Services, S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo import fields, models + + +class StockMove(models.Model): + _inherit = 'stock.move' + + orderpoint_ids = fields.Many2many( + comodel_name='stock.warehouse.orderpoint', + string='Linked Reordering Rules', + ) + + def _prepare_procurement_values(self): + res = super(StockMove, self)._prepare_procurement_values() + if self.orderpoint_ids: + res['orderpoint_ids'] = self.orderpoint_ids + return res + + def _merge_moves_fields(self): + res = super(StockMove, self)._merge_moves_fields() + res['orderpoint_ids'] = [(4, m.id) + for m in self.mapped('orderpoint_ids')] + return res diff --git a/stock_orderpoint_move_link/static/description/icon.png b/stock_orderpoint_move_link/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/stock_orderpoint_move_link/static/description/icon.png differ diff --git a/stock_orderpoint_move_link/views/stock_move_views.xml b/stock_orderpoint_move_link/views/stock_move_views.xml new file mode 100644 index 000000000..7975bdedc --- /dev/null +++ b/stock_orderpoint_move_link/views/stock_move_views.xml @@ -0,0 +1,28 @@ + + + + + + stock.move.form + stock.move + + + + + + + + + + stock.move.form + stock.move + + + + + + + + +