diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/mrp_subcontracting_account/models | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/mrp_subcontracting_account/models')
| -rw-r--r-- | addons/mrp_subcontracting_account/models/__init__.py | 4 | ||||
| -rw-r--r-- | addons/mrp_subcontracting_account/models/stock_picking.py | 25 |
2 files changed, 29 insertions, 0 deletions
diff --git a/addons/mrp_subcontracting_account/models/__init__.py b/addons/mrp_subcontracting_account/models/__init__.py new file mode 100644 index 00000000..ac951744 --- /dev/null +++ b/addons/mrp_subcontracting_account/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import stock_picking diff --git a/addons/mrp_subcontracting_account/models/stock_picking.py b/addons/mrp_subcontracting_account/models/stock_picking.py new file mode 100644 index 00000000..087c60c0 --- /dev/null +++ b/addons/mrp_subcontracting_account/models/stock_picking.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import models +from odoo.osv.expression import OR + + +class StockPicking(models.Model): + _inherit = 'stock.picking' + + def action_view_stock_valuation_layers(self): + action = super(StockPicking, self).action_view_stock_valuation_layers() + subcontracted_productions = self._get_subcontracted_productions() + if not subcontracted_productions: + return action + domain = action['domain'] + domain_subcontracting = [('id', 'in', (subcontracted_productions.move_raw_ids | subcontracted_productions.move_finished_ids).stock_valuation_layer_ids.ids)] + domain = OR([domain, domain_subcontracting]) + return dict(action, domain=domain) + + def _prepare_subcontract_mo_vals(self, subcontract_move, bom): + vals = super(StockPicking, self)._prepare_subcontract_mo_vals(subcontract_move, bom) + if bom.product_tmpl_id.cost_method in ('fifo', 'average'): + vals = dict(vals, extra_cost=subcontract_move._get_price_unit()) + return vals |
