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 Joan Sisquella
parent bae4fb7f2e
commit b1c61973e2
8 changed files with 156 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
.. 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 Purchase Link
==============================
This module adds to purchase order lines a direct link to the reordering rules
that created them. In chained moves, the reordering rule is propagated
from stock moves to the purchase order line.
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,2 @@
from . import models

View File

@@ -0,0 +1,22 @@
# 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 Purchase Link",
"summary": "Link Reordering rules to purchase orders",
"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_orderpoint_move_link",
"purchase",
],
"data": [
"views/purchase_order_views.xml",
],
"installable": True,
'auto_install': True,
}

View File

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

View File

@@ -0,0 +1,31 @@
# 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 _prepare_purchase_order_line(self, product_id, product_qty,
product_uom, values, po, supplier):
vals = super(ProcurementRule, self)._prepare_purchase_order_line(
product_id, product_qty, product_uom, values, po, supplier)
# If the procurement was run directly by a reordering rule.
if 'orderpoint_id' in values:
vals['orderpoint_ids'] = [
(4, values['orderpoint_id'].id)]
# If the procurement was run by a stock move.
elif 'orderpoint_ids' in values:
vals['orderpoint_ids'] = [(4, o.id)
for o in values['orderpoint_ids']]
return vals
def _update_purchase_order_line(self, product_id, product_qty, product_uom,
values, line, partner):
vals = super(ProcurementRule, self)._update_purchase_order_line(
product_id, product_qty, product_uom, values, line, partner)
if 'orderpoint_id' in values:
vals['orderpoint_ids'] = [
(4, values['orderpoint_id'].id)]
return vals

View File

@@ -0,0 +1,12 @@
# 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 api, fields, models
class PurchaseOrderLine(models.Model):
_inherit = 'purchase.order.line'
orderpoint_ids = fields.Many2many(
comodel_name='stock.warehouse.orderpoint',
string='Orderpoints', copy=False)

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -0,0 +1,35 @@
<?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="purchase_order_form" model="ir.ui.view">
<field name="name">purchase.order.form</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='button_box']" position="inside">
</xpath>
<xpath expr="//field[@name='order_line']/form/sheet/notebook"
position="inside">
<page name="orderpoints" string="Orderpoints"
groups="stock.group_stock_user">
<field name="orderpoint_ids"/>
</page>
</xpath>
</field>
</record>
<record id="purchase_order_line_form2" model="ir.ui.view">
<field name="name">purchase.order.line.form2</field>
<field name="model">purchase.order.line</field>
<field name="inherit_id" ref="purchase.purchase_order_line_form2"/>
<field name="arch" type="xml">
<field name="name" position="after">
<separator string="Orderpoints"/>
<field name="orderpoint_ids"/>
</field>
</field>
</record>
</odoo>