[IMP] mrp_production_real_cost: Load real cost from quant when product's cost method is real

This commit is contained in:
agaldona
2017-08-01 15:26:32 +02:00
parent cff012eda1
commit 7de43df2a1
2 changed files with 5 additions and 2 deletions

View File

@@ -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

View File

@@ -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')