summaryrefslogtreecommitdiff
path: root/addons/mrp
diff options
context:
space:
mode:
authorMartin Trigaux <mat@odoo.com>2019-07-16 09:14:17 +0000
committerMartin Trigaux <mat@odoo.com>2019-07-16 09:14:17 +0000
commitcf8e74a1a7d3404f57798573e8b15ce4dc5b9be4 (patch)
treebd95e9d20aff9b4f92550bffb2835a55c3698c27 /addons/mrp
parentb67a3bb403b80e98a2b66dcb8cf570d2b156fb68 (diff)
parent1bd434da34731b5467cc17fdffe6f3ed5dfea2d4 (diff)
[MERGE] Forward port of 12.0 to saas-12.2 up to 1bd434da34731b546
closes odoo/odoo#34901 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Diffstat (limited to 'addons/mrp')
-rw-r--r--addons/mrp/i18n/km.po22
-rw-r--r--addons/mrp/models/mrp_production.py14
-rw-r--r--addons/mrp/tests/test_order.py46
-rw-r--r--addons/mrp/wizard/change_production_qty.py11
4 files changed, 73 insertions, 20 deletions
diff --git a/addons/mrp/i18n/km.po b/addons/mrp/i18n/km.po
index ee0f635d6e1..13b79efc2c6 100644
--- a/addons/mrp/i18n/km.po
+++ b/addons/mrp/i18n/km.po
@@ -1225,7 +1225,7 @@ msgstr ""
#. module: mrp
#: model_terms:ir.ui.view,arch_db:mrp.report_mrporder
msgid "From"
-msgstr ""
+msgstr "មកពី"
#. module: mrp
#: model_terms:ir.ui.view,arch_db:mrp.oee_search_view
@@ -1240,7 +1240,7 @@ msgstr ""
#. module: mrp
#: model_terms:ir.ui.view,arch_db:mrp.view_mrp_production_filter
msgid "Future Activities"
-msgstr ""
+msgstr "សកម្មភាពទៅមុខ"
#. module: mrp
#: model_terms:ir.ui.view,arch_db:mrp.mrp_workcenter_view
@@ -1310,7 +1310,7 @@ msgstr ""
#. module: mrp
#: selection:mrp.document,priority:0
msgid "High"
-msgstr ""
+msgstr "ខ្ពស់"
#. module: mrp
#: model:ir.model.fields,field_description:mrp.field_change_production_qty__id
@@ -1450,7 +1450,7 @@ msgstr ""
#. module: mrp
#: selection:stock.picking.type,code:0
msgid "Internal"
-msgstr ""
+msgstr "ផ្ទៃក្នុង"
#. module: mrp
#: model:ir.actions.act_window,name:mrp.action_mrp_production_moves
@@ -1601,7 +1601,7 @@ msgstr ""
#: model_terms:ir.ui.view,arch_db:mrp.mrp_unbuild_search_view
#: model_terms:ir.ui.view,arch_db:mrp.view_mrp_production_filter
msgid "Late Activities"
-msgstr ""
+msgstr "សកម្មភាពចុងក្រោយ"
#. module: mrp
#: model:product.product,description:mrp.product_product_wood_ply
@@ -1685,7 +1685,7 @@ msgstr ""
#. module: mrp
#: selection:mrp.document,priority:0
msgid "Low"
-msgstr ""
+msgstr "ខាត"
#. module: mrp
#: model:ir.model.fields,field_description:mrp.field_res_config_settings__group_mrp_routings
@@ -2246,7 +2246,7 @@ msgstr ""
#. module: mrp
#: model:ir.ui.menu,name:mrp.menu_mrp_dashboard
msgid "Overview"
-msgstr ""
+msgstr "ទិដ្ឋភាពទូទៅ"
#. module: mrp
#: model:ir.model.fields,field_description:mrp.field_mrp_bom_line__bom_id
@@ -3638,7 +3638,7 @@ msgstr ""
#: model:ir.model.fields,field_description:mrp.field_mrp_workorder__product_tracking
#: model:ir.model.fields,field_description:mrp.field_stock_move__needs_lots
msgid "Tracking"
-msgstr ""
+msgstr "ការ​តាមដាន"
#. module: mrp
#: model:ir.model.fields,field_description:mrp.field_mrp_document__type
@@ -3736,7 +3736,7 @@ msgstr ""
#: model:product.template,uom_name:mrp.product_product_wood_ply_product_template
#: model:product.template,uom_name:mrp.product_product_wood_wear_product_template
msgid "Unit(s)"
-msgstr ""
+msgstr "កំរិត(s)"
#. module: mrp
#: model_terms:ir.ui.view,arch_db:mrp.mrp_production_form_view
@@ -3829,7 +3829,7 @@ msgstr ""
#. module: mrp
#: selection:mrp.document,priority:0
msgid "Very High"
-msgstr ""
+msgstr "ខ្ពស់​ណាស់"
#. module: mrp
#: selection:mrp.production,priority:0
@@ -4346,7 +4346,7 @@ msgstr ""
#: model:product.template,weight_uom_name:mrp.product_product_wood_ply_product_template
#: model:product.template,weight_uom_name:mrp.product_product_wood_wear_product_template
msgid "kg"
-msgstr ""
+msgstr "គីឡូ"
#. module: mrp
#: model_terms:ir.ui.view,arch_db:mrp.mrp_routing_workcenter_form_view
diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py
index 3162d02db3f..e3b3fc2a611 100644
--- a/addons/mrp/models/mrp_production.py
+++ b/addons/mrp/models/mrp_production.py
@@ -568,12 +568,13 @@ class MrpProduction(models.Model):
move[0]._recompute_state()
move[0]._action_assign()
move[0].unit_factor = quantity / move[0].raw_material_production_id.product_qty
- elif quantity < 0: # Do not remove 0 lines
+ return move[0], old_qty, quantity
+ else:
if move[0].quantity_done > 0:
raise UserError(_('Lines need to be deleted, but can not as you still have some quantities to consume in them. '))
move[0]._action_cancel()
move[0].unlink()
- return move[0], old_qty, quantity
+ return self.env['stock.move'], old_qty, quantity
else:
move_values = self._get_move_raw_values(bom_line, line_data)
move = self.env['stock.move'].create(move_values)
@@ -847,15 +848,14 @@ class MrpProduction(models.Model):
raise UserError(_('Work order %s is still running') % wo.name)
self._check_lots()
- # Cancel unfinished move
- move_to_cancel = self.move_raw_ids.filtered(lambda m: m.state not in ('done', 'cancel') and float_is_zero(m.quantity_done, precision_rounding=m.product_uom.rounding))
- move_to_cancel._action_cancel()
-
self.post_inventory()
# Moves without quantity done are not posted => set them as done instead of canceling. In
# case the user edits the MO later on and sets some consumed quantity on those, we do not
# want the move lines to be canceled.
- (self.move_raw_ids | self.move_finished_ids).filtered(lambda x: x.state not in ('done', 'cancel')).write({'state': 'done'})
+ (self.move_raw_ids | self.move_finished_ids).filtered(lambda x: x.state not in ('done', 'cancel')).write({
+ 'state': 'done',
+ 'product_uom_qty': 0.0,
+ })
self.write({'date_finished': fields.Datetime.now()})
return True
diff --git a/addons/mrp/tests/test_order.py b/addons/mrp/tests/test_order.py
index 1445e240e97..5bfbec8df12 100644
--- a/addons/mrp/tests/test_order.py
+++ b/addons/mrp/tests/test_order.py
@@ -5,6 +5,7 @@ from odoo.tests import Form
from datetime import datetime, timedelta
from odoo.fields import Datetime as Dt
+from odoo.exceptions import UserError
from odoo.addons.mrp.tests.common import TestMrpCommon
@@ -692,6 +693,51 @@ class TestMrpOrder(TestMrpCommon):
mo.button_mark_done()
def test_product_produce_6(self):
+ """ Plan 5 finished products, reserve and produce 3. Post the current production.
+ Simulate an unlock and edit and, on the opened moves, set the consumed quantity
+ to 3. Now, try to update the quantity to produce to 3. It should fail since there
+ are consumed quantities. Unlock and edit, remove the consumed quantities and
+ update the quantity to produce to 3."""
+ self.stock_location = self.env.ref('stock.stock_location_stock')
+ mo, bom, p_final, p1, p2 = self.generate_mo()
+ self.assertEqual(len(mo), 1, 'MO should have been created')
+
+ self.env['stock.quant']._update_available_quantity(p1, self.stock_location, 20)
+
+ self.env['stock.quant']._update_available_quantity(p2, self.stock_location, 5)
+ mo.action_assign()
+
+ produce_wizard = self.env['mrp.product.produce'].with_context({
+ 'active_id': mo.id,
+ 'active_ids': [mo.id],
+ }).create({
+ 'product_qty': 3.0,
+ })
+ produce_wizard._onchange_product_qty()
+ produce_wizard.do_produce()
+
+ mo.post_inventory()
+ self.assertEqual(len(mo.move_raw_ids), 4)
+
+ mo.move_raw_ids.filtered(lambda m: m.state != 'done')[0].quantity_done = 3
+
+ update_quantity_wizard = self.env['change.production.qty'].create({
+ 'mo_id': mo.id,
+ 'product_qty': 3,
+ })
+ with self.assertRaises(UserError):
+ update_quantity_wizard.change_prod_qty()
+
+ mo.move_raw_ids.filtered(lambda m: m.state != 'done')[0].quantity_done = 0
+ update_quantity_wizard.change_prod_qty()
+
+ self.assertEqual(len(mo.move_raw_ids), 2)
+
+ mo.button_mark_done()
+ self.assertTrue(all(s == 'done' for s in mo.move_raw_ids.mapped('state')))
+ self.assertEqual(sum(mo.move_raw_ids.mapped('move_line_ids.product_uom_qty')), 0)
+
+ def test_product_produce_6(self):
""" Build some final products and change the quantity to produce
directly in the wizard. The component line should be updated .
"""
diff --git a/addons/mrp/wizard/change_production_qty.py b/addons/mrp/wizard/change_production_qty.py
index 9e40bb63b67..e98364f9b93 100644
--- a/addons/mrp/wizard/change_production_qty.py
+++ b/addons/mrp/wizard/change_production_qty.py
@@ -57,15 +57,22 @@ class ChangeProductionQty(models.TransientModel):
if line.child_bom_id and line.child_bom_id.type == 'phantom' or\
line.product_id.type not in ['product', 'consu']:
continue
- move, old_qty, new_qty = production._update_raw_move(line, line_data)
+ move = production.move_raw_ids.filtered(lambda x: x.bom_line_id.id == line.id and x.state not in ('done', 'cancel'))
+ if move:
+ old_qty = move[0].product_uom_qty
+ else:
+ old_qty = 0
iterate_key = production._get_document_iterate_key(move)
if iterate_key:
- document = self.env['stock.picking']._log_activity_get_documents({move: (new_qty, old_qty)}, iterate_key, 'UP')
+ document = self.env['stock.picking']._log_activity_get_documents({move: (line_data['qty'], old_qty)}, iterate_key, 'UP')
for key, value in document.items():
if documents.get(key):
documents[key] += [value]
else:
documents[key] = [value]
+
+ production._update_raw_move(line, line_data)
+
production._log_manufacture_exception(documents)
operation_bom_qty = {}
for bom, bom_data in boms: