[FIX] mrp: force readonly=False on compute

Commit 167c51b1f9 makes `use_create_lots`
and 'use_exisitng_lots` computed fields in MRP module but did not mark
them as `readonly=False`. Thus, they were readonly by default for any
picking types.

Also, make sure new reception picking type have their `use_create_lots`
set to True and delivery picking type their `use_existing_lots` set to
True.

closes odoo/odoo#135900

Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
This commit is contained in:
William Henrotin
2023-09-19 17:44:33 +00:00
parent 98452d37cb
commit 3186133064
3 changed files with 14 additions and 4 deletions
-2
View File
@@ -16,8 +16,6 @@ class StockPickingType(models.Model):
compute='_get_mo_count')
count_mo_late = fields.Integer(string="Number of Manufacturing Orders Late",
compute='_get_mo_count')
use_create_lots = fields.Boolean(compute='_compute_use_create_lots', store=True)
use_existing_lots = fields.Boolean(compute='_compute_use_existing_lots', store=True)
use_create_components_lots = fields.Boolean(
string="Create New Lots/Serial Numbers for Components",
help="Allow to create new lot/serial numbers for the components",
+14
View File
@@ -57,9 +57,11 @@ class PickingType(models.Model):
active = fields.Boolean('Active', default=True)
use_create_lots = fields.Boolean(
'Create New Lots/Serial Numbers', default=True,
compute='_compute_use_create_lots', store=True, readonly=False,
help="If this is checked only, it will suppose you want to create new Lots/Serial Numbers, so you can provide them in a text field. ")
use_existing_lots = fields.Boolean(
'Use Existing Lots/Serial Numbers', default=True,
compute='_compute_use_existing_lots', store=True, readonly=False,
help="If this is checked, you will be able to choose the Lots/Serial Numbers. You can also decide to not put lots in this operation type. This means it will create stock with no lot or not put a restriction on the lot taken. ")
print_label = fields.Boolean(
'Print Label',
@@ -174,6 +176,18 @@ class PickingType(models.Model):
else:
picking_type.display_name = picking_type.name
@api.depends('code')
def _compute_use_create_lots(self):
for picking_type in self:
if picking_type.code == 'incoming':
picking_type.use_create_lots = True
@api.depends('code')
def _compute_use_existing_lots(self):
for picking_type in self:
if picking_type.code == 'outgoing':
picking_type.use_existing_lots = True
@api.model
def _name_search(self, name, domain=None, operator='ilike', limit=None, order=None):
# Try to reverse the `display_name` structure
-2
View File
@@ -954,7 +954,6 @@ class Warehouse(models.Model):
'in_type_id': {
'name': _('Receipts'),
'code': 'incoming',
'use_create_lots': True,
'use_existing_lots': False,
'default_location_src_id': False,
'sequence': max_sequence + 1,
@@ -966,7 +965,6 @@ class Warehouse(models.Model):
'name': _('Delivery Orders'),
'code': 'outgoing',
'use_create_lots': False,
'use_existing_lots': True,
'default_location_dest_id': False,
'sequence': max_sequence + 5,
'sequence_code': 'OUT',