add stock_orderpoint_move_link and stock_orderpoint_purchase_link

This commit is contained in:
Jordi Ballester Alomar
2018-05-16 01:47:07 +02:00
committed by Guewen Baconnier
parent fcb0c7db81
commit 6e50fc1826
8 changed files with 148 additions and 0 deletions

View File

@@ -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
<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 smash it by providing detailed and welcomed feedback.
Credits
=======
Contributors
------------
* Jordi Ballester <jordi.ballester@eficent.com>
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.

View File

@@ -0,0 +1 @@
from . import models

View File

@@ -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,
}

View File

@@ -0,0 +1,2 @@
from . import procurement_rule
from . import stock_move

View File

@@ -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

View File

@@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<!-- Copyright 2016 Eficent Business and IT Consulting Services S.L.
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0) -->
<odoo>
<record id="view_move_picking_form" model="ir.ui.view">
<field name="name">stock.move.form</field>
<field name="model">stock.move</field>
<field name="inherit_id" ref="stock.view_move_picking_form"/>
<field name="arch" type="xml">
<field name="move_dest_ids" position="after">
<field name="orderpoint_ids"/>
</field>
</field>
</record>
<record id="view_move_form" model="ir.ui.view">
<field name="name">stock.move.form</field>
<field name="model">stock.move</field>
<field name="inherit_id" ref="stock.view_move_form"/>
<field name="arch" type="xml">
<field name="move_dest_ids" position="after">
<field name="orderpoint_ids"/>
</field>
</field>
</record>
</odoo>