mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
add stock_orderpoint_move_link and stock_orderpoint_purchase_link
This commit is contained in:
committed by
Joan Sisquella
parent
bae4fb7f2e
commit
b1c61973e2
52
stock_orderpoint_purchase_link/README.rst
Normal file
52
stock_orderpoint_purchase_link/README.rst
Normal 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.
|
||||
2
stock_orderpoint_purchase_link/__init__.py
Normal file
2
stock_orderpoint_purchase_link/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
from . import models
|
||||
22
stock_orderpoint_purchase_link/__manifest__.py
Normal file
22
stock_orderpoint_purchase_link/__manifest__.py
Normal 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,
|
||||
}
|
||||
2
stock_orderpoint_purchase_link/models/__init__.py
Normal file
2
stock_orderpoint_purchase_link/models/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import purchase_order_line
|
||||
from . import procurement_rule
|
||||
31
stock_orderpoint_purchase_link/models/procurement_rule.py
Normal file
31
stock_orderpoint_purchase_link/models/procurement_rule.py
Normal 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
|
||||
12
stock_orderpoint_purchase_link/models/purchase_order_line.py
Normal file
12
stock_orderpoint_purchase_link/models/purchase_order_line.py
Normal 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)
|
||||
BIN
stock_orderpoint_purchase_link/static/description/icon.png
Normal file
BIN
stock_orderpoint_purchase_link/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
@@ -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>
|
||||
Reference in New Issue
Block a user