[FIX] purchase: sections and notes.
https://github.com/odoo/odoo/pull/34737 didn't go in enough depth to ensure sections and notes don't break purchase flows. closes odoo/odoo#39474 X-original-commit: 1e8ea4f5628878dbc667c27d4e76ab42d3f140ea Signed-off-by: Damien Bouvy (dbo) <dbo@odoo.com>
This commit is contained in:
@@ -538,7 +538,7 @@ class PurchaseOrderLine(models.Model):
|
||||
@api.depends('product_id')
|
||||
def _compute_qty_received_method(self):
|
||||
for line in self:
|
||||
if line.product_id.type in ['consu', 'service']:
|
||||
if line.product_id and line.product_id.type in ['consu', 'service']:
|
||||
line.qty_received_method = 'manual'
|
||||
else:
|
||||
line.qty_received_method = False
|
||||
@@ -697,7 +697,7 @@ class PurchaseOrderLine(models.Model):
|
||||
@api.depends('product_uom', 'product_qty', 'product_id.uom_id')
|
||||
def _compute_product_uom_qty(self):
|
||||
for line in self:
|
||||
if line.product_id.uom_id != line.product_uom:
|
||||
if line.product_id and line.product_id.uom_id != line.product_uom:
|
||||
line.product_uom_qty = line.product_uom._compute_quantity(line.product_qty, line.product_id.uom_id)
|
||||
else:
|
||||
line.product_uom_qty = line.product_qty
|
||||
|
||||
@@ -242,7 +242,7 @@ class PurchaseOrderLine(models.Model):
|
||||
|
||||
def _compute_qty_received_method(self):
|
||||
super(PurchaseOrderLine, self)._compute_qty_received_method()
|
||||
for line in self:
|
||||
for line in self.filtered(lambda l: not l.display_type):
|
||||
if line.product_id.type in ['consu', 'product']:
|
||||
line.qty_received_method = 'stock_moves'
|
||||
|
||||
@@ -275,7 +275,7 @@ class PurchaseOrderLine(models.Model):
|
||||
return line
|
||||
|
||||
def write(self, values):
|
||||
for line in self:
|
||||
for line in self.filtered(lambda l: not l.display_type):
|
||||
if values.get('date_planned') and line.propagate_date:
|
||||
new_date = fields.Datetime.to_datetime(values['date_planned'])
|
||||
delta_days = (new_date - line.date_planned).total_seconds() / 86400
|
||||
@@ -297,7 +297,7 @@ class PurchaseOrderLine(models.Model):
|
||||
|
||||
def _create_or_update_picking(self):
|
||||
for line in self:
|
||||
if line.product_id.type in ('product', 'consu'):
|
||||
if line.product_id and line.product_id.type in ('product', 'consu'):
|
||||
# Prevent decreasing below received quantity
|
||||
if float_compare(line.product_qty, line.qty_received, line.product_uom.rounding) < 0:
|
||||
raise UserError(_('You cannot decrease the ordered quantity below the received quantity.\n'
|
||||
@@ -394,7 +394,7 @@ class PurchaseOrderLine(models.Model):
|
||||
|
||||
def _create_stock_moves(self, picking):
|
||||
values = []
|
||||
for line in self:
|
||||
for line in self.filtered(lambda l: not l.display_type):
|
||||
for val in line._prepare_stock_moves(picking):
|
||||
values.append(val)
|
||||
return self.env['stock.move'].create(values)
|
||||
|
||||
@@ -90,7 +90,7 @@ class StockRule(models.Model):
|
||||
procurements = self._merge_procurements(procurements_to_merge)
|
||||
|
||||
po_lines_by_product = {}
|
||||
grouped_po_lines = groupby(po.order_line.filtered(lambda l: l.product_uom == l.product_id.uom_po_id).sorted('product_id'), key=lambda l: l.product_id.id)
|
||||
grouped_po_lines = groupby(po.order_line.filtered(lambda l: not l.display_type and l.product_uom == l.product_id.uom_po_id).sorted('product_id'), key=lambda l: l.product_id.id)
|
||||
for product, po_lines in grouped_po_lines:
|
||||
po_lines_by_product[product] = self.env['purchase.order.line'].concat(*list(po_lines))
|
||||
po_line_values = []
|
||||
|
||||
Reference in New Issue
Block a user