Skip to content

Commit

Permalink
[IMP] allow change state of invoices on child companies linked to doc…
Browse files Browse the repository at this point in the history
…uments on parent ones
  • Loading branch information
jjscarafia committed Jun 18, 2018
1 parent e3cff7e commit 382021d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
12 changes: 9 additions & 3 deletions purchase_multic_fix/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion purchase_multic_fix/purchase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions sale_multic_fix/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit 382021d

Please sign in to comment.