Browse Source

[FIX] Fixed Issue #440 (when calling Scheduled Actions)

pull/442/head
Nikul Chaudhary 5 years ago
parent
commit
53eba74a77
  1. 10
      contract_sale_invoicing/models/contract.py
  2. 7
      contract_sale_invoicing/tests/test_contract_sale_invoicing.py

10
contract_sale_invoicing/models/contract.py

@ -16,16 +16,18 @@ class ContractContract(models.Model):
@api.multi @api.multi
def _recurring_create_invoice(self, date_ref=False): def _recurring_create_invoice(self, date_ref=False):
invoices = super()._recurring_create_invoice(date_ref) invoices = super()._recurring_create_invoice(date_ref)
if not self.invoicing_sales:
for rec in self:
if not rec.invoicing_sales:
return invoices return invoices
sales = self.env['sale.order'].search([ sales = self.env['sale.order'].search([
('analytic_account_id', '=', self.group_id.id),
('analytic_account_id', '=', rec.group_id.id),
('partner_invoice_id', 'child_of', ('partner_invoice_id', 'child_of',
self.partner_id.commercial_partner_id.ids),
rec.partner_id.commercial_partner_id.ids),
('invoice_status', '=', 'to invoice'), ('invoice_status', '=', 'to invoice'),
('date_order', '<=', ('date_order', '<=',
'{} 23:59:59'.format(self.recurring_next_date)),
'{} 23:59:59'.format(rec.recurring_next_date)),
]) ])
if sales: if sales:
invoice_ids = sales.action_invoice_create() invoice_ids = sales.action_invoice_create()
invoices |= self.env['account.invoice'].browse(invoice_ids)[:1] invoices |= self.env['account.invoice'].browse(invoice_ids)[:1]
return invoices

7
contract_sale_invoicing/tests/test_contract_sale_invoicing.py

@ -45,3 +45,10 @@ class TestContractSaleInvoicing(TestContractBase):
self.sale_order.action_confirm() self.sale_order.action_confirm()
self.contract.recurring_create_invoice() self.contract.recurring_create_invoice()
self.assertEqual(self.sale_order.invoice_status, 'to invoice') self.assertEqual(self.sale_order.invoice_status, 'to invoice')
def test_multi_contract_recurring_create_invoice(self):
self.contract.copy()
self.contract.copy()
self.contract.copy()
self.contract.copy()
self.env['contract.contract'].cron_recurring_create_invoice()
Loading…
Cancel
Save