From 962a81384d616f9d0a3b0b8edbebac8f76135a8a Mon Sep 17 00:00:00 2001 From: Aaron Henriquez Date: Wed, 15 May 2019 18:31:21 +0200 Subject: [PATCH] [FIX]type error purchase analytic --- rma_purchase_analytic/models/purchase_order_line.py | 6 +++--- rma_purchase_analytic/wizards/rma_add_purchase.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rma_purchase_analytic/models/purchase_order_line.py b/rma_purchase_analytic/models/purchase_order_line.py index 4d42752bb..044600f9a 100644 --- a/rma_purchase_analytic/models/purchase_order_line.py +++ b/rma_purchase_analytic/models/purchase_order_line.py @@ -8,10 +8,10 @@ class PurchaseOrderLine(models.Model): _inherit = "purchase.order.line" - @api.constrains('analytic_account_id') + @api.constrains('account_analytic_id') def check_analytic(self): - for line in self: - if (line.analytic_account_id != + for line in self.filtered(lambda p: p.rma_line_id): + if (line.account_analytic_id != line.rma_line_id.analytic_account_id): raise exceptions.ValidationError( _("The analytic account in the PO line it's not the same" diff --git a/rma_purchase_analytic/wizards/rma_add_purchase.py b/rma_purchase_analytic/wizards/rma_add_purchase.py index 5a084711e..7d79194e5 100644 --- a/rma_purchase_analytic/wizards/rma_add_purchase.py +++ b/rma_purchase_analytic/wizards/rma_add_purchase.py @@ -22,5 +22,5 @@ class RmaLineMakePurchaseOrder(models.TransientModel): @api.model def _prepare_purchase_order_line(self, po, item): res = super(RmaLineMakePurchaseOrder, self)._prepare_purchase_order_line(po, item) - res['analytic_account_id'] = item.line_id.analytic_account_id.id + res['account_analytic_id'] = item.line_id.analytic_account_id.id return res