Browse Source

Merge pull request #132 from Tecnativa/11.0-IMP-contract-contract_count

[11.0][IMP] contract: Improve partner contract smartbutton
pull/153/head
Pedro M. Baeza 7 years ago
committed by GitHub
parent
commit
6f02ba8503
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      contract/models/account_analytic_account.py
  2. 6
      contract/models/res_partner.py
  3. 9
      contract/views/account_analytic_account_view.xml

3
contract/models/account_analytic_account.py

@ -240,7 +240,8 @@ class AccountAnalyticAccount(models.Model):
invoice = self.env['account.invoice'].create(invoice_vals)
for line in self.recurring_invoice_line_ids:
invoice_line_vals = self._prepare_invoice_line(line, invoice.id)
self.env['account.invoice.line'].create(invoice_line_vals)
if invoice_line_vals:
self.env['account.invoice.line'].create(invoice_line_vals)
invoice.compute_taxes()
return invoice

6
contract/models/res_partner.py

@ -18,8 +18,7 @@ class ResPartner(models.Model):
for partner in self:
partner.contract_count = Contract.search_count([
('recurring_invoices', '=', True),
('partner_id', '=', partner.id),
('date_start', '<=', today),
('partner_id', 'child_of', partner.ids),
'|',
('date_end', '=', False),
('date_end', '>=', today),
@ -37,9 +36,10 @@ class ResPartner(models.Model):
self.env.context,
search_default_recurring_invoices=True,
search_default_not_finished=True,
search_default_partner_id=self.id,
default_partner_id=self.id,
default_recurring_invoices=True,
default_pricelist_id=self.pricelist_id.id,
),
domain=[('partner_id', '=', self.id)],
)
return res

9
contract/views/account_analytic_account_view.xml

@ -116,12 +116,11 @@
<field name="model">account.analytic.account</field>
<field name="inherit_id" ref="analytic.view_account_analytic_account_search"/>
<field name="arch" type="xml">
<field name="partner_id" position="after">
<field name="partner_id" filter_domain="[('partner_id', 'child_of', self)]"
string="Partner and dependents"/>
</field>
<field name="name" position="after">
<field name="partner_id" position="after">
<!-- Use other field because partner_id already used -->
<field name="company_id" filter_domain="[('partner_id', 'child_of', self)]"
string="Partner and dependents"/>
</field>
<field name="journal_id"/>
<field name="pricelist_id"/>
<separator/>

Loading…
Cancel
Save