-
-
Notifications
You must be signed in to change notification settings - Fork 486
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da308c1
commit a9e376b
Showing
17 changed files
with
802 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,79 @@ | ||
=========================== | ||
MRP Stock Owner Restriction | ||
=========================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:00dc2315a91f43ef42e2ae6f4d5657da81307bbe2f4856dd21bc1f3d48c7ee86 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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_stock_owner_restriction | ||
: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_stock_owner_restriction | ||
: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 adapts the functionality of stock_owner_restriction in the manufacturing | ||
order. | ||
|
||
**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_stock_owner_restriction%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 | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* `Quartile <https://www.quartile.co>`_: | ||
|
||
* Yoshi Tashiro | ||
|
||
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_stock_owner_restriction>`_ 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 2023 Quartile Limited | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "MRP Stock Owner Restriction", | ||
"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", "stock_owner_restriction"], | ||
"data": ["views/mrp_production_views.xml"], | ||
"installable": True, | ||
} |
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,46 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * mrp_stock_owner_restriction | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2023-04-12 07:13+0000\n" | ||
"PO-Revision-Date: 2023-04-12 07:13+0000\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: mrp_stock_owner_restriction | ||
#: model:ir.model.fields,field_description:mrp_stock_owner_restriction.field_mrp_production__owner_id | ||
msgid "Assign Owner" | ||
msgstr "オーナー割当" | ||
|
||
#. module: mrp_stock_owner_restriction | ||
#: model:ir.model.fields,field_description:mrp_stock_owner_restriction.field_mrp_production__owner_restriction | ||
msgid "Owner Restriction" | ||
msgstr "オーナー制限" | ||
|
||
#. module: mrp_stock_owner_restriction | ||
#: model:ir.model.fields,help:mrp_stock_owner_restriction.field_mrp_production__owner_id | ||
msgid "Produced products will be assigned to this owner." | ||
msgstr "生産された製品は、このオーナーに割り当てられます。" | ||
|
||
#. module: mrp_stock_owner_restriction | ||
#: model:ir.model,name:mrp_stock_owner_restriction.model_stock_move_line | ||
msgid "Product Moves (Stock Move Line)" | ||
msgstr "製品の移動(在庫移動ライン)" | ||
|
||
#. module: mrp_stock_owner_restriction | ||
#: model:ir.model,name:mrp_stock_owner_restriction.model_mrp_production | ||
msgid "Production Order" | ||
msgstr "製造オーダ" | ||
|
||
#. module: mrp_stock_owner_restriction | ||
#: model:ir.model,name:mrp_stock_owner_restriction.model_stock_move | ||
msgid "Stock Move" | ||
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,4 @@ | ||
from . import mrp_production | ||
from . import mrp_unbuild | ||
from . import stock_move_line | ||
from . import stock_move |
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,26 @@ | ||
# Copyright 2023 Quartile Limited | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class MrpProduction(models.Model): | ||
_inherit = "mrp.production" | ||
|
||
owner_id = fields.Many2one( | ||
"res.partner", | ||
"Assign Owner", | ||
readonly=True, | ||
states={"draft": [("readonly", False)], "confirmed": [("readonly", False)]}, | ||
check_company=True, | ||
help="Produced products will be assigned to this owner.", | ||
) | ||
owner_restriction = fields.Selection(related="picking_type_id.owner_restriction") | ||
|
||
def write(self, vals): | ||
if "owner_id" in vals: | ||
for production in self: | ||
owner_restriction = self.picking_type_id.owner_restriction | ||
if owner_restriction in ("unassigned_owner", "picking_partner"): | ||
production.move_line_raw_ids.unlink() | ||
return super().write(vals) |
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,26 @@ | ||
# Copyright 2023 Quartile Limited | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class MrpUnbuild(models.Model): | ||
_inherit = "mrp.unbuild" | ||
|
||
# FIXME handle unbuild cases without MO | ||
# owner_id = fields.Many2one( | ||
# "res.partner", | ||
# "Assign Owner", | ||
# readonly=True, | ||
# states={"draft": [("readonly", False)], "confirmed": [("readonly", False)]}, | ||
# check_company=True, | ||
# help="Produced products will be assigned to this owner.", | ||
# ) | ||
# owner_restriction = fields.Selection(related="picking_type_id.owner_restriction") | ||
|
||
def action_validate(self): | ||
owner_restriction = self.mo_id.picking_type_id.owner_restriction | ||
owner = self.mo_id.owner_id | ||
if owner and owner_restriction in ("unassigned_owner", "picking_partner"): | ||
self = self.with_context(force_restricted_owner_id=owner) | ||
return super().action_validate() |
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,42 @@ | ||
# Copyright 2023 Quartile Limited | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, models | ||
|
||
|
||
class StockMove(models.Model): | ||
_inherit = "stock.move" | ||
|
||
# Just to add a trigger | ||
@api.depends("production_id.owner_id") | ||
def _compute_restrict_partner_id(self): | ||
return super()._compute_restrict_partner_id() | ||
|
||
def _get_mo_to_unbuild(self): | ||
self.ensure_one() | ||
return self.consume_unbuild_id.mo_id or self.unbuild_id.mo_id | ||
|
||
def _get_owner_for_assign(self): | ||
self.ensure_one() | ||
if self.raw_material_production_id: | ||
return self.raw_material_production_id.owner_id | ||
# Manufactured product should not consider the owner for assignment, or the | ||
# result might be messed up (e.g. tries to move stock from the internal location | ||
# instead of the production location). | ||
if self.production_id: | ||
return False | ||
# For chained origin moves for production component moves. | ||
production = self.move_dest_ids.raw_material_production_id | ||
if production: | ||
return production.owner_id | ||
mo_to_unbuild = self._get_mo_to_unbuild() | ||
if mo_to_unbuild: | ||
return mo_to_unbuild.owner_id | ||
return super()._get_owner_for_assign() | ||
|
||
def _get_owner_restriction(self): | ||
self.ensure_one() | ||
mo_to_unbuild = self._get_mo_to_unbuild() | ||
if mo_to_unbuild: | ||
return mo_to_unbuild.picking_type_id.owner_restriction | ||
return super()._get_owner_restriction() | ||
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,18 @@ | ||
# Copyright 2023 Quartile Limited | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class StockMoveLine(models.Model): | ||
_inherit = "stock.move.line" | ||
|
||
def _action_done(self): | ||
for line in self: | ||
owner = line.move_id.production_id.owner_id or self.env.context.get( | ||
"force_restricted_owner_id", None | ||
) | ||
if owner: | ||
line.move_id.write({"restrict_partner_id": owner.id}) | ||
line.write({"owner_id": owner.id}) | ||
return super()._action_done() |
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 @@ | ||
* `Quartile <https://www.quartile.co>`_: | ||
|
||
* Yoshi Tashiro |
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 @@ | ||
This module adapts the functionality of stock_owner_restriction in the manufacturing | ||
order. |
Oops, something went wrong.