[FIX] stock: fix various bug in picking views
The following bugs in detailed operations have been fixed in this commit: - Avoid to edit reserved quantity on move lines. When a picking is set in 'UNLOCK' mode you are able to edit the reserved quantity of move lines, even if it doesn't really causes problems it create confusion on what is the reserved quantity. - Avoid to edit the product_id on a move if there is a move lines linked to it. This will cause inceonsistencies by having move lines with product_id different than the related moves. - Avoid to edit the product_id on a move line if it has a linked move for the same reasons as above. We also avoid the edition when picking is done to avoid issues with the stock valuation - Remove call to 'force_assign' method on demo data as this method is not used anymore and set some pickings in wierd states - Adding a move line in the detailed operation view does not create an associated move. - Don't allow editing moves when we are in detailed views and state is done, even if picking is unlocked. TASK-1817931
This commit is contained in:
@@ -342,11 +342,6 @@
|
||||
record_chi_in = self.browse(ref('incomming_chicago_warehouse1'))
|
||||
record_chi_out = self.browse(ref('outgoing_chicago_warehouse1'))
|
||||
if record.state != 'done' and record_chi_in.state != 'done' and record_chi_out.state != 'done':
|
||||
self.browse([
|
||||
ref('outgoing_shipment_main_warehouse'),
|
||||
ref('outgoing_chicago_warehouse3'),
|
||||
ref('outgoing_shipment_main_warehouse2')
|
||||
]).force_assign()
|
||||
self.browse([
|
||||
ref('outgoing_shipment_main_warehouse1'),
|
||||
ref('incomming_chicago_warehouse1'),
|
||||
|
||||
@@ -158,6 +158,7 @@ class StockMove(models.Model):
|
||||
is_initial_demand_editable = fields.Boolean('Is initial demand editable', compute='_compute_is_initial_demand_editable')
|
||||
is_quantity_done_editable = fields.Boolean('Is quantity done editable', compute='_compute_is_quantity_done_editable')
|
||||
reference = fields.Char(compute='_compute_reference', string="Reference", store=True)
|
||||
has_move_lines = fields.Boolean(compute='_compute_has_move_lines')
|
||||
|
||||
@api.depends('picking_id.is_locked')
|
||||
def _compute_is_locked(self):
|
||||
@@ -217,6 +218,8 @@ class StockMove(models.Model):
|
||||
move.is_quantity_done_editable = False
|
||||
elif move.show_details_visible:
|
||||
move.is_quantity_done_editable = False
|
||||
elif move.show_operations:
|
||||
move.is_quantity_done_editable = False
|
||||
else:
|
||||
move.is_quantity_done_editable = True
|
||||
|
||||
@@ -225,6 +228,11 @@ class StockMove(models.Model):
|
||||
for move in self:
|
||||
move.reference = move.picking_id.name if move.picking_id else move.name
|
||||
|
||||
@api.depends('move_line_ids')
|
||||
def _compute_has_move_lines(self):
|
||||
for move in self:
|
||||
move.has_move_lines = bool(move.move_line_ids)
|
||||
|
||||
@api.one
|
||||
@api.depends('product_id', 'product_uom', 'product_uom_qty')
|
||||
def _compute_product_qty(self):
|
||||
|
||||
@@ -167,7 +167,7 @@ class StockMoveLine(models.Model):
|
||||
# If the move line is directly create on the picking view.
|
||||
# If this picking is already done we should generate an
|
||||
# associated done move.
|
||||
if 'picking_id' in vals and 'move_id' not in vals:
|
||||
if 'picking_id' in vals and not vals.get('move_id'):
|
||||
picking = self.env['stock.picking'].browse(vals['picking_id'])
|
||||
if picking.state == 'done':
|
||||
product = self.env['product.product'].browse(vals['product_id'])
|
||||
|
||||
@@ -259,7 +259,8 @@
|
||||
<page string="Detailed Operations" attrs="{'invisible': [('show_operations', '=', False)]}">
|
||||
<field name="move_line_ids" attrs="{'readonly': [('state', '=', 'done'), ('is_locked', '=', True)]}" context="{'default_picking_id': id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id}">
|
||||
<tree editable="bottom" decoration-muted="(state == 'done' and is_locked == True)" decoration-danger="qty_done>product_uom_qty and state!='done'" decoration-success="qty_done==product_uom_qty and state!='done' and not result_package_id">
|
||||
<field name="product_id" required="1"/>
|
||||
<field name="product_id" required="1" attrs="{'readonly': ['|', ('state', '=', 'done'), ('move_id', '!=', False)]}"/>
|
||||
<field name="move_id" invisible="1"/>
|
||||
<field name="in_entire_package" invisible="1"/>
|
||||
<field name="product_uom_id" force_save="1" attrs="{'readonly': [('state', '!=', 'draft')]}" groups="product.group_uom"/>
|
||||
<field name="package_id" attrs="{'readonly': [('in_entire_package', '=', True)]}" groups="stock.group_tracking_lot" domain="[('location_id', '=', location_id)]"/>
|
||||
@@ -272,7 +273,7 @@
|
||||
<field name="lot_id" groups="stock.group_production_lot" attrs="{'column_invisible': [('parent.show_lots_text', '=', True)], 'invisible': [('lots_visible', '=', False)], 'readonly': [('in_entire_package', '=', True)]}" domain="[('product_id', '=', product_id)]" context="{'default_product_id': product_id}"/>
|
||||
<field name="lot_name" groups="stock.group_production_lot" attrs="{'column_invisible': [('parent.show_lots_text', '=', False)], 'invisible': [('lots_visible', '=', False)], 'readonly': [('in_entire_package', '=', True)]}" context="{'default_product_id': product_id}"/>
|
||||
<field name="is_initial_demand_editable" invisible="1"/>
|
||||
<field name="product_uom_qty" attrs="{'readonly': ['|', ('is_initial_demand_editable', '=', False), ('in_entire_package', '=', True)], 'required': [('product_id', '!=', False)]}"/>
|
||||
<field name="product_uom_qty" readonly="1"/>
|
||||
<field name="is_locked" invisible="1"/>
|
||||
<field name="qty_done" attrs="{'readonly': ['|', ('state', 'in', ('done', 'cancel')), ('is_locked', '=', True), ('in_entire_package', '=', True)]}" force_save="1"/>
|
||||
</tree>
|
||||
@@ -282,7 +283,7 @@
|
||||
</page>
|
||||
<page string="Operations">
|
||||
<field name="id" invisible="1"/>
|
||||
<field name="move_lines" attrs="{'readonly': ['|', ('show_operations', '=', True), '&', ('state', '=', 'done'), ('is_locked', '=', True)]}" context="{'picking_type_code': picking_type_code, 'default_picking_id': id, 'form_view_ref':'stock.view_move_picking_form', 'address_in_id': partner_id, 'default_picking_type_id': picking_type_id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id}">
|
||||
<field name="move_lines" attrs="{'readonly': ['|', '&', ('show_operations', '=', True), '|', ('is_locked', '=', True), ('state', '=', 'done'), '&', ('state', '=', 'done'), ('is_locked', '=', True)]}" context="{'picking_type_code': picking_type_code, 'default_picking_id': id, 'form_view_ref':'stock.view_move_picking_form', 'address_in_id': partner_id, 'default_picking_type_id': picking_type_id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id}">
|
||||
<tree decoration-danger="state != 'done' and quantity_done > reserved_availability and show_reserved_availability" decoration-muted="scrapped == True or state == 'cancel' or (state == 'done' and is_locked == True)" string="Stock Moves" editable="bottom">
|
||||
<field name="name" invisible="1"/>
|
||||
<field name="date_expected" invisible="1"/>
|
||||
@@ -297,8 +298,9 @@
|
||||
<field name="show_reserved_availability" invisible="1"/>
|
||||
<field name="show_operations" invisible="1" readonly="1"/>
|
||||
<field name="additional" invisible="1"/>
|
||||
<field name="has_move_lines" invisible="1"/>
|
||||
<field name="is_locked" invisible="1"/>
|
||||
<field name="product_id" required="1" attrs="{'readonly': ['&', ('state', '!=', 'draft'), ('additional', '=', False)]}"/>
|
||||
<field name="product_id" required="1" attrs="{'readonly': ['|', '&', ('state', '!=', 'draft'), ('additional', '=', False), ('has_move_lines', '=', True)]}"/>
|
||||
<field name="is_initial_demand_editable" invisible="1"/>
|
||||
<field name="is_quantity_done_editable" invisible="1"/>
|
||||
<field name="product_uom_qty" string="Initial Demand" attrs="{'readonly': [('is_initial_demand_editable', '=', False)]}"/>
|
||||
|
||||
Reference in New Issue
Block a user