diff --git a/addons/purchase/models/purchase_order_line.py b/addons/purchase/models/purchase_order_line.py index 0360c0cb173..74d7e6cfc3e 100644 --- a/addons/purchase/models/purchase_order_line.py +++ b/addons/purchase/models/purchase_order_line.py @@ -89,7 +89,7 @@ class PurchaseOrderLine(models.Model): def _compute_amount(self): for line in self: tax_results = self.env['account.tax']._compute_taxes([line._convert_to_tax_base_line_dict()]) - totals = list(tax_results['totals'].values())[0] + totals = next(iter(tax_results['totals'].values())) amount_untaxed = totals['amount_untaxed'] amount_tax = totals['amount_tax'] @@ -564,9 +564,11 @@ class PurchaseOrderLine(models.Model): ) def _validate_analytic_distribution(self): - for line in self.filtered(lambda l: not l.display_type): - line._validate_distribution(**{ - 'product': line.product_id.id, - 'business_domain': 'purchase_order', - 'company_id': line.company_id.id, - }) + for line in self: + if line.display_type: + continue + line._validate_distribution( + product=line.product_id.id, + business_domain='purchase_order', + company_id=line.company_id.id, + ) diff --git a/addons/purchase_stock/models/purchase_order.py b/addons/purchase_stock/models/purchase_order.py index 35233691782..9d684c35caf 100644 --- a/addons/purchase_stock/models/purchase_order.py +++ b/addons/purchase_stock/models/purchase_order.py @@ -131,9 +131,9 @@ class PurchaseOrder(models.Model): for pick in order.picking_ids.filtered(lambda r: r.state != 'cancel'): pick.action_cancel() - order.order_line.write({'move_dest_ids':[(5,0,0)]}) + order.order_line.write({'move_dest_ids': [(5, 0, 0)]}) - return super(PurchaseOrder, self).button_cancel() + return super().button_cancel() def action_view_picking(self): return self._get_action_view_picking(self.picking_ids) diff --git a/addons/purchase_stock/models/purchase_order_line.py b/addons/purchase_stock/models/purchase_order_line.py index fd2c8eceed9..4b1c1612273 100644 --- a/addons/purchase_stock/models/purchase_order_line.py +++ b/addons/purchase_stock/models/purchase_order_line.py @@ -213,14 +213,14 @@ class PurchaseOrderLine(models.Model): move_dests = self.move_dest_ids if not move_dests: - move_dests = self.move_ids.move_dest_ids.filtered(lambda m: m.state != 'cancel' and not m.location_dest_id.usage == 'supplier') + move_dests = self.move_ids.move_dest_ids.filtered(lambda m: m.state != 'cancel' and m.location_dest_id.usage != 'supplier') if not move_dests: qty_to_attach = 0 qty_to_push = self.product_qty - qty else: move_dests_initial_demand = self.product_id.uom_id._compute_quantity( - sum(move_dests.filtered(lambda m: m.state != 'cancel' and not m.location_dest_id.usage == 'supplier').mapped('product_qty')), + sum(move_dests.filtered(lambda m: m.state != 'cancel' and m.location_dest_id.usage != 'supplier').mapped('product_qty')), self.product_uom, rounding_method='HALF-UP') qty_to_attach = move_dests_initial_demand - qty qty_to_push = self.product_qty - move_dests_initial_demand