mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
Merge pull request #165 from agaldona/8.0-real_cost
[IMP] mrp_production_real_cost: load production unit cost in final product quants
This commit is contained in:
@@ -75,6 +75,11 @@ class StockMove(models.Model):
|
||||
for product_id, product_data in products.iteritems():
|
||||
new_price = self._new_average_price(product_data)
|
||||
product_data['product'].sudo().standard_price = new_price
|
||||
real_moves = self.filtered(
|
||||
lambda x: (x.production_id and x.product_id.cost_method == 'real'))
|
||||
for move in real_moves:
|
||||
move.mapped('quant_ids').write({'cost':
|
||||
move.production_id.unit_real_cost})
|
||||
|
||||
@api.model
|
||||
def get_price_unit(self, move):
|
||||
|
||||
@@ -71,6 +71,19 @@ class TestMrpProductionRealCost(common.TransactionCase):
|
||||
self.assertNotEqual(
|
||||
initial_price, self.production.product_id.standard_price)
|
||||
|
||||
def test_produce_real(self):
|
||||
self.production.product_id.cost_method = 'real'
|
||||
for line in self.production.workcenter_lines:
|
||||
line.signal_workflow('button_start_working')
|
||||
line.operation_time_lines[-1].start_date = self.start_date
|
||||
line.operation_time_lines[-1].end_date = (
|
||||
self.start_date + (timedelta(hours=3)))
|
||||
self.production.action_produce(
|
||||
self.production.id, self.production.product_qty, 'consume_produce')
|
||||
self.assertTrue(self.production.unit_real_cost)
|
||||
for quant in self.production.mapped('move_created_ids2.quant_ids'):
|
||||
self.assertEqual(quant.cost, self.production.unit_real_cost)
|
||||
|
||||
def test_onchange_lines_default(self):
|
||||
workcenter0 = self.browse_ref('mrp.mrp_workcenter_0')
|
||||
routing = self.env['mrp.routing.workcenter'].new({
|
||||
|
||||
Reference in New Issue
Block a user