From 382021d40100aad43daaaf7e6ab46f1bba57a00e Mon Sep 17 00:00:00 2001 From: Juan Jose Scarafia Date: Mon, 18 Jun 2018 10:28:50 -0300 Subject: [PATCH] [IMP] allow change state of invoices on child companies linked to documents on parent ones --- purchase_multic_fix/account_invoice.py | 12 +++++++++--- purchase_multic_fix/purchase.py | 8 +++++++- sale_multic_fix/models/sale_order.py | 6 ++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/purchase_multic_fix/account_invoice.py b/purchase_multic_fix/account_invoice.py index 2f0f5eb2..d0c0990c 100644 --- a/purchase_multic_fix/account_invoice.py +++ b/purchase_multic_fix/account_invoice.py @@ -3,11 +3,17 @@ # For copyright and license notices, see __openerp__.py file in module root # directory ############################################################################## -from openerp import models +from openerp import models, fields -class AccountInvoice(models.Model): - _inherit = "account.invoice" +class AccountInvoiceLine(models.Model): + _inherit = "account.invoice.line" + + # this is tu fix when you are on a child company on an invoice linked to + # a PO of the parent company + purchase_id = fields.Many2one( + related_sudo=True, + ) # al final este arreglo no fue necesario por cambios en _onchange_company # de account_multic_fix diff --git a/purchase_multic_fix/purchase.py b/purchase_multic_fix/purchase.py index 83be96a3..2c7ed333 100644 --- a/purchase_multic_fix/purchase.py +++ b/purchase_multic_fix/purchase.py @@ -3,7 +3,7 @@ # For copyright and license notices, see __openerp__.py file in module root # directory ############################################################################## -from openerp import models, api, _ +from openerp import models, api, fields, _ class purchase_order(models.Model): @@ -22,6 +22,12 @@ def check_company(self): class purchase_order_line(models.Model): _inherit = "purchase.order.line" + # this is tu fix when you are on a child company and you change state of an + # invoice linked to a PO of parent company (validate it, set as paid, etc) + qty_invoiced = fields.Float( + compute_sudo=True, + ) + @api.onchange('product_id') def onchange_product_id(self): res = super(purchase_order_line, self).onchange_product_id() diff --git a/sale_multic_fix/models/sale_order.py b/sale_multic_fix/models/sale_order.py index 02b4fd3f..2663d080 100644 --- a/sale_multic_fix/models/sale_order.py +++ b/sale_multic_fix/models/sale_order.py @@ -88,6 +88,12 @@ def _prepare_invoice(self): class SaleOrderLine(models.Model): _inherit = "sale.order.line" + # this is tu fix when you are on a child company and you change state of an + # invoice linked to a SO of parent company (validate it, set as paid, etc) + qty_invoiced = fields.Float( + compute_sudo=True, + ) + @api.multi def _prepare_invoice_line(self, qty): """