mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[REF] Contract Sale Invoicing: split from analytic account
[REF] Contract Sale Invoicing: update translations [IMP] - Assert that the predecessor is available for new link at uncancel [RMV] - remove usless changes [RMV] - Remove usless field recurring_invoices after the total isolation between contract model and account analytic one. recurring_invoices which was used to mark analytic account as contract became usless [IMP] - P3 syntax [IMP] - use @openupgrade.migrate() and openupgrade.logged_query [IMP] - drop transient table in migration script
This commit is contained in:
committed by
sbejaoui
parent
24f57be03d
commit
a429b10c20
@@ -4,8 +4,8 @@
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class AccountAnalyticAccount(models.Model):
|
||||
_inherit = 'account.analytic.account'
|
||||
class ContractContract(models.Model):
|
||||
_inherit = 'contract.contract'
|
||||
|
||||
invoicing_sales = fields.Boolean(
|
||||
string='Invoice Pending Sales Orders',
|
||||
@@ -14,11 +14,12 @@ class AccountAnalyticAccount(models.Model):
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def _create_invoice(self, invoice=False):
|
||||
def _recurring_create_invoice(self, date_ref=False):
|
||||
invoices = super()._recurring_create_invoice(date_ref)
|
||||
if not self.invoicing_sales:
|
||||
return super(AccountAnalyticAccount, self)._create_invoice()
|
||||
return invoices
|
||||
sales = self.env['sale.order'].search([
|
||||
('analytic_account_id', '=', self.id),
|
||||
('analytic_account_id', '=', self.analytic_account_id.id),
|
||||
('partner_invoice_id', 'child_of',
|
||||
self.partner_id.commercial_partner_id.ids),
|
||||
('invoice_status', '=', 'to invoice'),
|
||||
@@ -27,6 +28,4 @@ class AccountAnalyticAccount(models.Model):
|
||||
])
|
||||
if sales:
|
||||
invoice_ids = sales.action_invoice_create()
|
||||
invoice = self.env['account.invoice'].browse(invoice_ids)[:1]
|
||||
return super(AccountAnalyticAccount, self)._create_invoice(
|
||||
invoice=invoice)
|
||||
invoices |= self.env['account.invoice'].browse(invoice_ids)[:1]
|
||||
|
||||
Reference in New Issue
Block a user