mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[IMP] - Contract product are ignored on invoicing process
- Sale order line for contract product pass to nothing to invoice on order confirmation - Contract Invoices are linked to sale order line
This commit is contained in:
committed by
Thomas Binsfeld
parent
3c882b6764
commit
147c40acaa
@@ -2,7 +2,7 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
from odoo import fields, models
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class AccountAnalyticInvoiceLine(models.Model):
|
||||
@@ -14,3 +14,12 @@ class AccountAnalyticInvoiceLine(models.Model):
|
||||
required=False,
|
||||
copy=False,
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def _prepare_invoice_line(self, invoice_id):
|
||||
res = super(AccountAnalyticInvoiceLine, self)._prepare_invoice_line(
|
||||
invoice_id
|
||||
)
|
||||
if self.sale_order_line_id:
|
||||
res['sale_line_ids'] = [(6, 0, [self.sale_order_line_id.id])]
|
||||
return res
|
||||
|
||||
@@ -24,9 +24,11 @@ class SaleOrder(models.Model):
|
||||
contract_env = self.env['account.analytic.account']
|
||||
for rec in self.filtered('is_contract'):
|
||||
line_to_create_contract = rec.order_line.filtered(
|
||||
lambda r: not r.contract_id
|
||||
lambda r: not r.contract_id and r.product_id.is_contract
|
||||
)
|
||||
line_to_update_contract = rec.order_line.filtered(
|
||||
lambda r: r.contract_id and r.product_id.is_contract
|
||||
)
|
||||
line_to_update_contract = rec.order_line.filtered('contract_id')
|
||||
for contract_template in line_to_create_contract.mapped(
|
||||
'product_id.contract_template_id'
|
||||
):
|
||||
|
||||
@@ -113,3 +113,14 @@ class SaleOrderLine(models.Model):
|
||||
raise ValidationError(
|
||||
_("Contract product has different contract template")
|
||||
)
|
||||
|
||||
def _compute_invoice_status(self):
|
||||
super(SaleOrderLine, self)._compute_invoice_status()
|
||||
for line in self.filtered('contract_id'):
|
||||
line.invoice_status = 'no'
|
||||
|
||||
@api.multi
|
||||
def invoice_line_create(self, invoice_id, qty):
|
||||
return super(
|
||||
SaleOrderLine, self.filtered(lambda l: not l.contract_id)
|
||||
).invoice_line_create(invoice_id, qty)
|
||||
|
||||
Reference in New Issue
Block a user