Skip to content

Commit

Permalink
[IMP] mrp_stock_owner_restriction: add handling of umbuild orders
Browse files Browse the repository at this point in the history
  • Loading branch information
AungKoKoLin1997 committed Nov 13, 2023
1 parent 0136449 commit 83a43c3
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 1 deletion.
46 changes: 46 additions & 0 deletions mrp_stock_owner_restriction/i18n/ja.po
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 "在庫移動"
1 change: 1 addition & 0 deletions mrp_stock_owner_restriction/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import mrp_production
from . import mrp_unbuild
from . import stock_move_line
from . import stock_move
15 changes: 15 additions & 0 deletions mrp_stock_owner_restriction/models/mrp_unbuild.py
Original file line number Diff line number Diff line change
@@ -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()
14 changes: 14 additions & 0 deletions mrp_stock_owner_restriction/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()
4 changes: 3 additions & 1 deletion mrp_stock_owner_restriction/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

0 comments on commit 83a43c3

Please sign in to comment.