diff --git a/mrp_stock_owner_restriction/i18n/ja.po b/mrp_stock_owner_restriction/i18n/ja.po new file mode 100644 index 00000000000..bcdbfc42091 --- /dev/null +++ b/mrp_stock_owner_restriction/i18n/ja.po @@ -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 "在庫移動" diff --git a/mrp_stock_owner_restriction/models/__init__.py b/mrp_stock_owner_restriction/models/__init__.py index 8085f8f3f66..a228c032172 100644 --- a/mrp_stock_owner_restriction/models/__init__.py +++ b/mrp_stock_owner_restriction/models/__init__.py @@ -1,3 +1,4 @@ from . import mrp_production +from . import mrp_unbuild from . import stock_move_line from . import stock_move diff --git a/mrp_stock_owner_restriction/models/mrp_unbuild.py b/mrp_stock_owner_restriction/models/mrp_unbuild.py new file mode 100644 index 00000000000..a9912b4c4c2 --- /dev/null +++ b/mrp_stock_owner_restriction/models/mrp_unbuild.py @@ -0,0 +1,15 @@ +# 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" + + 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 != "standard_behavior": + self = self.with_context(force_restricted_owner_id=owner) + return super().action_validate() diff --git a/mrp_stock_owner_restriction/models/stock_move.py b/mrp_stock_owner_restriction/models/stock_move.py index 920c07dbb66..46889455796 100644 --- a/mrp_stock_owner_restriction/models/stock_move.py +++ b/mrp_stock_owner_restriction/models/stock_move.py @@ -7,6 +7,10 @@ class StockMove(models.Model): _inherit = "stock.move" + 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: @@ -20,4 +24,14 @@ def _get_owner_for_assign(self): 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() diff --git a/mrp_stock_owner_restriction/models/stock_move_line.py b/mrp_stock_owner_restriction/models/stock_move_line.py index d5a4d21a736..5cad5a0bb95 100644 --- a/mrp_stock_owner_restriction/models/stock_move_line.py +++ b/mrp_stock_owner_restriction/models/stock_move_line.py @@ -9,7 +9,9 @@ class StockMoveLine(models.Model): def _action_done(self): for line in self: - owner = line.move_id.production_id.owner_id + 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})