forked from OCA/purchase-workflow
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '14.0-mig-purchase_line_procurement_group' of https://gi…
…thub.com/decgroupe/purchase-workflow into 14.0
- Loading branch information
Showing
19 changed files
with
968 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
=============================== | ||
Purchase Line Procurement Group | ||
=============================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! 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%2Fpurchase--workflow-lightgray.png?logo=github | ||
:target: https://github.com/OCA/purchase-workflow/tree/14.0/purchase_line_procurement_group | ||
:alt: OCA/purchase-workflow | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/purchase-workflow-14-0/purchase-workflow-14-0-purchase_line_procurement_group | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/purchase-workflow&target_branch=14.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module changes the way procurements generate purchase order lines. | ||
If some procurements are run for the same products and locations, but have | ||
different procurement groups, these won't be merged in the same purchase order | ||
line and will instead generate a purchase order line per procurement group. | ||
|
||
Moreover this module ensures that generated stock move won't be merged together | ||
if they come from purchase order lines with different procurement groups. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/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/purchase-workflow/issues/new?body=module:%20purchase_line_procurement_group%0Aversion:%2014.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 | ||
~~~~~~~ | ||
|
||
* Camptocamp | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Akim Juillerat <[email protected]> | ||
* Kitti Upariphutthiphong <[email protected]> | ||
* Phuc Tran Thanh <[email protected]> | ||
|
||
Other credits | ||
~~~~~~~~~~~~~ | ||
|
||
The development of this module has been financially supported by: | ||
|
||
* Camptocamp | ||
|
||
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/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/14.0/purchase_line_procurement_group>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright 2018 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Purchase Line Procurement Group", | ||
"summary": "Group purchase order line according to procurement group", | ||
"version": "14.0.1.0.0", | ||
"category": "Purchase", | ||
"website": "https://github.com/OCA/purchase-workflow", | ||
"author": "Camptocamp, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"depends": ["purchase_stock"], | ||
"data": ["views/purchase.xml"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * purchase_line_procurement_group | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 12.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"PO-Revision-Date: 2020-10-04 16:24+0000\n" | ||
"Last-Translator: Yann Papouin <[email protected]>\n" | ||
"Language-Team: none\n" | ||
"Language: fr\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: nplurals=2; plural=n > 1;\n" | ||
"X-Generator: Weblate 3.10\n" | ||
|
||
#. module: purchase_line_procurement_group | ||
#: model:ir.model.fields,field_description:purchase_line_procurement_group.field_purchase_order_line__procurement_group_id | ||
msgid "Procurement Group" | ||
msgstr "Groupe d'approvisionnement" | ||
|
||
#. module: purchase_line_procurement_group | ||
#: model:ir.model,name:purchase_line_procurement_group.model_purchase_order_line | ||
msgid "Purchase Order Line" | ||
msgstr "Ligne de commande d'achat" | ||
|
||
#. module: purchase_line_procurement_group | ||
#: model:ir.model,name:purchase_line_procurement_group.model_stock_move | ||
msgid "Stock Move" | ||
msgstr "Mouvement de stock" | ||
|
||
#. module: purchase_line_procurement_group | ||
#: model:ir.model,name:purchase_line_procurement_group.model_stock_rule | ||
msgid "Stock Rule" | ||
msgstr "Règle de stock" |
34 changes: 34 additions & 0 deletions
34
purchase_line_procurement_group/i18n/purchase_line_procurement_group.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * purchase_line_procurement_group | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 13.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: purchase_line_procurement_group | ||
#: model:ir.model.fields,field_description:purchase_line_procurement_group.field_purchase_order_line__procurement_group_id | ||
msgid "Procurement Group" | ||
msgstr "" | ||
|
||
#. module: purchase_line_procurement_group | ||
#: model:ir.model,name:purchase_line_procurement_group.model_purchase_order_line | ||
msgid "Purchase Order Line" | ||
msgstr "" | ||
|
||
#. module: purchase_line_procurement_group | ||
#: model:ir.model,name:purchase_line_procurement_group.model_stock_move | ||
msgid "Stock Move" | ||
msgstr "" | ||
|
||
#. module: purchase_line_procurement_group | ||
#: model:ir.model,name:purchase_line_procurement_group.model_stock_rule | ||
msgid "Stock Rule" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * purchase_line_procurement_group | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 12.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"PO-Revision-Date: 2019-09-02 14:40+0000\n" | ||
"Last-Translator: 黎伟杰 <[email protected]>\n" | ||
"Language-Team: none\n" | ||
"Language: zh_CN\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: nplurals=1; plural=0;\n" | ||
"X-Generator: Weblate 3.8\n" | ||
|
||
#. module: purchase_line_procurement_group | ||
#: model:ir.model.fields,field_description:purchase_line_procurement_group.field_purchase_order_line__procurement_group_id | ||
msgid "Procurement Group" | ||
msgstr "补货组" | ||
|
||
#. module: purchase_line_procurement_group | ||
#: model:ir.model,name:purchase_line_procurement_group.model_purchase_order_line | ||
msgid "Purchase Order Line" | ||
msgstr "采购订单行" | ||
|
||
#. module: purchase_line_procurement_group | ||
#: model:ir.model,name:purchase_line_procurement_group.model_stock_move | ||
msgid "Stock Move" | ||
msgstr "库存移动" | ||
|
||
#. module: purchase_line_procurement_group | ||
#: model:ir.model,name:purchase_line_procurement_group.model_stock_rule | ||
msgid "Stock Rule" | ||
msgstr "库存规则" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import purchase_order_line | ||
from . import stock_move |
58 changes: 58 additions & 0 deletions
58
purchase_line_procurement_group/models/purchase_order_line.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Copyright 2018 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from odoo import fields, models | ||
|
||
|
||
class PurchaseOrderLine(models.Model): | ||
_inherit = "purchase.order.line" | ||
|
||
procurement_group_id = fields.Many2one("procurement.group") | ||
|
||
def _find_candidate( | ||
self, | ||
product_id, | ||
product_qty, | ||
product_uom, | ||
location_id, | ||
name, | ||
origin, | ||
company_id, | ||
values, | ||
): | ||
"""Do not merge PO lines if procurement group is different or not set.""" | ||
_self = self | ||
if "group_id" in values: | ||
pg_id = values.get("group_id", False) | ||
if pg_id: | ||
pg_id = pg_id.id | ||
_self = self.filtered(lambda l: l.procurement_group_id.id == pg_id) | ||
return super(PurchaseOrderLine, _self)._find_candidate( | ||
product_id=product_id, | ||
product_qty=product_qty, | ||
product_uom=product_uom, | ||
location_id=location_id, | ||
name=name, | ||
origin=origin, | ||
company_id=company_id, | ||
values=values, | ||
) | ||
|
||
def _prepare_stock_moves(self, picking): | ||
res = super()._prepare_stock_moves(picking) | ||
if res and res[0] and "group_id" in res[0]: | ||
res[0]["group_id"] = ( | ||
self.procurement_group_id.id or self.order_id.group_id.id | ||
) | ||
return res | ||
|
||
def _prepare_purchase_order_line_from_procurement( | ||
self, product_id, product_qty, product_uom, company_id, values, po | ||
): | ||
"""Add procurement group to values""" | ||
res = super()._prepare_purchase_order_line_from_procurement( | ||
product_id, product_qty, product_uom, company_id, values, po | ||
) | ||
procurement_group = values.get("group_id") | ||
if procurement_group: | ||
res["procurement_group_id"] = procurement_group.id | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright 2018 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from odoo import api, models | ||
|
||
|
||
class StockMove(models.Model): | ||
|
||
_inherit = "stock.move" | ||
|
||
@api.model | ||
def _prepare_merge_moves_distinct_fields(self): | ||
res = super()._prepare_merge_moves_distinct_fields() | ||
res.append("group_id") | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* Akim Juillerat <[email protected]> | ||
* Kitti Upariphutthiphong <[email protected]> | ||
* Phuc Tran Thanh <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
The development of this module has been financially supported by: | ||
|
||
* Camptocamp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
This module changes the way procurements generate purchase order lines. | ||
If some procurements are run for the same products and locations, but have | ||
different procurement groups, these won't be merged in the same purchase order | ||
line and will instead generate a purchase order line per procurement group. | ||
|
||
Moreover this module ensures that generated stock move won't be merged together | ||
if they come from purchase order lines with different procurement groups. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.