-
-
Notifications
You must be signed in to change notification settings - Fork 498
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] mrp_subcontracting_purchase_stock_price_unit_sync
- Loading branch information
1 parent
006a592
commit 8bb3d62
Showing
9 changed files
with
539 additions
and
0 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
mrp_subcontracting_purchase_stock_price_unit_sync/README.rst
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,71 @@ | ||
================================================= | ||
MRP Subcontracting Purchase Stock Price Unit Sync | ||
================================================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:6f93d0dcae77bf05e855e383612aff22b4b811c4e03247807871badbf5aa3501 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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%2Fmanufacture-lightgray.png?logo=github | ||
:target: https://github.com/OCA/manufacture/tree/16.0/mrp_subcontracting_purchase_stock_price_unit_sync | ||
:alt: OCA/manufacture | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-mrp_subcontracting_purchase_stock_price_unit_sync | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/manufacture&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module extends 'purchase_stock_price_unit' functionality to also work with subcontracting purchase orders. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/manufacture/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_subcontracting_purchase_stock_price_unit_sync%0Aversion:%2016.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 | ||
~~~~~~~ | ||
|
||
* Quartile Limited | ||
|
||
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/manufacture <https://github.com/OCA/manufacture/tree/16.0/mrp_subcontracting_purchase_stock_price_unit_sync>`_ 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 |
12 changes: 12 additions & 0 deletions
12
mrp_subcontracting_purchase_stock_price_unit_sync/__manifest__.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,12 @@ | ||
# Copyright 2023 Quartile Limited | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "MRP Subcontracting Purchase Stock Price Unit Sync", | ||
"version": "16.0.1.0.0", | ||
"category": "Manufacturing", | ||
"website": "https://github.com/OCA/manufacture", | ||
"author": "Quartile Limited, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"depends": ["mrp_subcontracting", "purchase_stock_price_unit_sync"], | ||
"installable": True, | ||
} |
1 change: 1 addition & 0 deletions
1
mrp_subcontracting_purchase_stock_price_unit_sync/models/__init__.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 @@ | ||
from . import purchase_order |
32 changes: 32 additions & 0 deletions
32
mrp_subcontracting_purchase_stock_price_unit_sync/models/purchase_order.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,32 @@ | ||
# Copyright 2023 Quartile Limited | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class PurchaseOrderLine(models.Model): | ||
_inherit = "purchase.order.line" | ||
|
||
def stock_price_unit_sync(self): | ||
for line in self.filtered(lambda l: l.state in ["purchase", "done"]): | ||
move_ids = line.move_ids | ||
if move_ids.is_subcontract and move_ids.move_orig_ids.production_id: | ||
move_ids.move_orig_ids.write( | ||
{"price_unit": line._get_stock_move_price_unit()} | ||
) | ||
svls = ( | ||
move_ids.move_orig_ids.sudo() | ||
.mapped("stock_valuation_layer_ids") | ||
.filtered( | ||
# Filter children SVLs (like landed cost) | ||
lambda x: not x.stock_valuation_layer_id | ||
) | ||
) | ||
svls.write( | ||
{ | ||
"unit_cost": line.with_context( | ||
skip_stock_price_unit_sync=True | ||
)._get_stock_move_price_unit(), | ||
} | ||
) | ||
return super().stock_price_unit_sync() |
1 change: 1 addition & 0 deletions
1
mrp_subcontracting_purchase_stock_price_unit_sync/readme/DESCRIPTION.rst
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 @@ | ||
This module extends 'purchase_stock_price_unit' functionality to also work with subcontracting purchase orders. |
Oops, something went wrong.