mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[IMP] mrp_production_real_cost: Load real cost from quant when product's cost method is real
This commit is contained in:
@@ -27,11 +27,13 @@ class StockMove(models.Model):
|
||||
record.work_order.routing_wc_line.routing_id.code or '',
|
||||
record.product_id.default_code or '',
|
||||
_('MAT')])
|
||||
amount = (-record.product_id.standard_price * record.product_qty)
|
||||
if record.product_id.cost_method == 'real':
|
||||
amount = sum([-x.cost * x.qty for x in record.quant_ids])
|
||||
analytic_vals = (production._prepare_real_cost_analytic_line(
|
||||
journal_id, name, production, record.product_id,
|
||||
workorder=record.work_order, qty=record.product_qty,
|
||||
amount=(-record.product_id.standard_price *
|
||||
record.product_qty)))
|
||||
amount=amount))
|
||||
task = task_obj.search([('mrp_production_id', '=', production.id),
|
||||
('workorder', '=', False)])
|
||||
analytic_vals['task_id'] = task and task[0].id or False
|
||||
|
||||
@@ -72,6 +72,7 @@ class TestMrpProductionRealCost(common.TransactionCase):
|
||||
initial_price, self.production.product_id.standard_price)
|
||||
|
||||
def test_produce_real(self):
|
||||
self.production.move_lines[:1].product_id.cost_method = 'real'
|
||||
self.production.product_id.cost_method = 'real'
|
||||
for line in self.production.workcenter_lines:
|
||||
line.signal_workflow('button_start_working')
|
||||
|
||||
Reference in New Issue
Block a user