[MERGE] forward port branch saas-12.2 up to 27e9c9e011

This commit is contained in:
Christophe Simonis
2019-03-27 19:17:30 +01:00
4 changed files with 28 additions and 14 deletions
+3 -3
View File
@@ -58,7 +58,7 @@ class MrpAbstractWorkorder(models.AbstractModel):
self.production_id.product_uom_id,
round=False
)
qty_todo = float_round(new_qty - sum(move_workorder_lines.mapped('qty_done')), precision_rounding=rounding)
qty_todo = float_round(new_qty - sum(move_workorder_lines.mapped('qty_to_consume')), precision_rounding=rounding)
# Remove or lower quantity on exisiting workorder lines
if float_compare(qty_todo, 0.0, precision_rounding=rounding) < 0:
@@ -95,7 +95,7 @@ class MrpAbstractWorkorder(models.AbstractModel):
if float_compare(qty_reserved_remaining, 0, precision_rounding=rounding) > 0:
qty_to_add = min(qty_reserved_remaining, qty_todo)
line_values['to_update'][workorder_line] = {
'qty_done': workorder_line.qty_done + qty_to_add,
'qty_done': workorder_line.qty_to_consume + qty_to_add,
'qty_to_consume': workorder_line.qty_to_consume + qty_to_add,
'qty_reserved': workorder_line.qty_reserved + qty_to_add,
}
@@ -104,7 +104,7 @@ class MrpAbstractWorkorder(models.AbstractModel):
if not workorder_line.qty_reserved and not workorder_line.lot_id and workorder_line.product_tracking != 'serial':
line_values['to_update'][workorder_line] = {
'qty_done': workorder_line.qty_done + qty_todo,
'qty_done': workorder_line.qty_to_consume + qty_todo,
'qty_to_consume': workorder_line.qty_to_consume + qty_todo,
}
qty_todo = 0
+10 -9
View File
@@ -108,15 +108,16 @@ class MrpWorkorder(models.Model):
@api.depends('production_id')
def _compute_final_lot_domain(self):
# check if self is not the first workorder in the list
if self.env['mrp.workorder'].search([('next_work_order_id', '=', self.id)]):
self.final_lot_domain = self.env['stock.production.lot'].search([
('use_next_on_work_order_id', '=', self.id),
]).ids
else:
self.final_lot_domain = self.env['stock.production.lot'].search([
('product_id', '=', self.product_id.id),
]).ids
for wo in self:
# check if self is not the first workorder in the list
if self.env['mrp.workorder'].search([('next_work_order_id', '=', wo.id)]):
wo.final_lot_domain = self.env['stock.production.lot'].search([
('use_next_on_work_order_id', '=', wo.id),
]).ids
else:
wo.final_lot_domain = self.env['stock.production.lot'].search([
('product_id', '=', wo.product_id.id),
]).ids
@api.multi
def name_get(self):
+14
View File
@@ -479,6 +479,20 @@ class TestMrpOrder(TestMrpCommon):
'active_id': mo.id,
'active_ids': [mo.id],
}))
# change the quantity done in one line
produce_form.workorder_line_ids._records[0]['qty_done'] = 1
# change the quantity producing
produce_form.qty_producing = 3
# check than all quantities are update correctly
line1 = produce_form.workorder_line_ids._records[0]
line2 = produce_form.workorder_line_ids._records[1]
self.assertEqual(line1['qty_to_consume'], 3, "Wrong quantity to consume")
self.assertEqual(line1['qty_done'], 3, "Wrong quantity done")
self.assertEqual(line2['qty_to_consume'], 12, "Wrong quantity to consume")
self.assertEqual(line2['qty_done'], 12, "Wrong quantity done")
product_produce = produce_form.save()
self.assertEqual(len(product_produce.workorder_line_ids), 2, 'You should have produce lines even the consumed products are not tracked.')
product_produce.do_produce()
+1 -2
View File
@@ -26,7 +26,7 @@
</div>
<label for="quantity_done" attrs="{'invisible': [('parent.state', '=', 'draft')]}"/>
<div class="o_row" attrs="{'invisible': [('parent.state', '=', 'draft')]}">
<span><field name="quantity_done" attrs="{'readonly': ['|', ('is_locked', '=', True), '|', ('finished_lots_exist', '=', True), ('has_tracking', '!=', 'none')]}" nolabel="1"/></span>
<span><field name="quantity_done" attrs="{'readonly': ['|', '|', ('move_line_ids', '!=', False), ('is_locked', '=', True), '|', ('finished_lots_exist', '=', True), ('has_tracking', '!=', 'none')]}" nolabel="1"/></span>
<span> / </span>
<span><field name="reserved_availability" nolabel="1"/></span>
</div>
@@ -55,7 +55,6 @@
<field name="lot_produced_id" options="{'no_open': True, 'no_create': True}" domain="[('id', 'in', parent.order_finished_lot_ids)]" invisible="not context.get('final_lots')"/>
<field name="product_uom_qty" string="Reserved" readonly="1"/>
<field name="qty_done"/>
<field name="product_qty" invisible="1"/>
<field name="workorder_id" invisible="1"/>
<field name="product_id" invisible="1"/>
<field name="product_uom_id" invisible="1"/>