Skip to content
Snippets Groups Projects
Commit 04f3cac5 authored by Arnold Moyaux's avatar Arnold Moyaux Committed by Nicolas Pierre
Browse files

[IMP] stock, mrp: computed picking type on stock.move.line

Easier to access and avoid overwrite in function to check picking type
on manufacturing order

closes odoo/odoo#75691

Enterprise-pr: https://github.com/odoo/enterprise/pull/20102


Related: odoo/enterprise#20102
Related: odoo/upgrade#2785
Signed-off-by: default avatarArnold Moyaux <amoyaux@users.noreply.github.com>
parent 41f7c7bc
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,16 @@ class StockMoveLine(models.Model):
workorder_id = fields.Many2one('mrp.workorder', 'Work Order', check_company=True)
production_id = fields.Many2one('mrp.production', 'Production Order', check_company=True)
@api.depends('production_id')
def _compute_picking_type_id(self):
line_to_remove = self.env['stock.move.line']
for line in self:
if not line.production_id:
continue
line.picking_type_id = line.production_id.picking_type_id
line_to_remove |= line
return super(StockMoveLine, self - line_to_remove)._compute_picking_type_id()
@api.model_create_multi
def create(self, values):
res = super(StockMoveLine, self).create(values)
......
......@@ -58,6 +58,8 @@ class StockMoveLine(models.Model):
location_dest_id = fields.Many2one('stock.location', 'To', domain="[('usage', '!=', 'view')]", check_company=True, required=True)
lots_visible = fields.Boolean(compute='_compute_lots_visible')
picking_code = fields.Selection(related='picking_id.picking_type_id.code', readonly=True)
picking_type_id = fields.Many2one(
'stock.picking.type', 'Operation type', compute='_compute_picking_type_id')
picking_type_use_create_lots = fields.Boolean(related='picking_id.picking_type_id.use_create_lots', readonly=True)
picking_type_use_existing_lots = fields.Boolean(related='picking_id.picking_type_id.use_existing_lots', readonly=True)
picking_type_entire_packs = fields.Boolean(related='picking_id.picking_type_id.show_entire_packs', readonly=True)
......@@ -81,6 +83,13 @@ class StockMoveLine(models.Model):
else:
line.lots_visible = line.product_id.tracking != 'none'
@api.depends('picking_id')
def _compute_picking_type_id(self):
self.picking_type_id = False
for line in self:
if line.picking_id:
line.picking_type_id = line.picking_id.picking_type_id
@api.depends('product_id', 'product_uom_id', 'product_uom_qty')
def _compute_product_qty(self):
for line in self:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment