[IMP] mrp*: make some MO's methods public

The `mrp.production` method `_pre_button_mark_done` will now be public
so it can be called since the web client.
This change is done in order to know if trying to mark as done a
production will return a wizard or not, which is needed in the new MRP
Display view since there is a delay before a MO is actually marked as
done and we don't want to see the wizard poping up after this delay but
before !

The method `_set_qty_producing` public is also public now because it's
called in `_onchange_producing` but saddly, the onchanges don't happen
in the MES view, so this way we can manually call it when needed.

task-3231200

Part-of: odoo/odoo#127250
This commit is contained in:
svs-odoo
2023-07-20 11:49:27 +02:00
committed by Arnold Moyaux
parent ff32acbb86
commit a467737420
3 changed files with 11 additions and 6 deletions
+7 -2
View File
@@ -1246,6 +1246,11 @@ class MrpProduction(models.Model):
parent_moves = self.procurement_group_id.stock_move_ids.move_dest_ids
return (dest_moves | parent_moves).group_id.mrp_production_ids.filtered(lambda p: p.origin != self.origin) - self
def set_qty_producing(self):
# This method is used to call `_set_lot_producing` when the onchange doesn't apply.
self.ensure_one()
self._set_qty_producing()
def _set_lot_producing(self):
self.ensure_one()
self.lot_producing_id = self.env['stock.lot'].create(self._prepare_stock_lot_values())
@@ -1882,7 +1887,7 @@ class MrpProduction(models.Model):
def button_mark_done(self):
self._button_mark_done_sanity_checks()
res = self._pre_button_mark_done()
res = self.pre_button_mark_done()
if res is not True:
return res
@@ -1963,7 +1968,7 @@ class MrpProduction(models.Model):
})
return action
def _pre_button_mark_done(self):
def pre_button_mark_done(self):
for production in self:
if float_is_zero(production.qty_producing, precision_rounding=production.product_uom_id.rounding):
production._set_quantities()
@@ -7,11 +7,11 @@ from odoo import models, _
class MrpWorkorder(models.Model):
_inherit = 'mrp.production'
def _pre_button_mark_done(self):
def pre_button_mark_done(self):
confirm_expired_lots = self._check_expired_lots()
if confirm_expired_lots:
return confirm_expired_lots
return super()._pre_button_mark_done()
return super().pre_button_mark_done()
def _check_expired_lots(self):
# We use the 'skip_expired' context key to avoid to make the check when
@@ -92,10 +92,10 @@ class MrpProduction(models.Model):
return action
return {'type': 'ir.actions.act_window_close'}
def _pre_button_mark_done(self):
def pre_button_mark_done(self):
if self._get_subcontract_move():
return True
return super()._pre_button_mark_done()
return super().pre_button_mark_done()
def _update_finished_move(self):
""" After producing, set the move line on the subcontract picking. """