Browse Source

[IMP] get account journal default by sequence

pull/315/head
sergiocorato 6 years ago
parent
commit
e1cfee911e
  1. 2
      contract/__manifest__.py
  2. 3
      contract/models/account_analytic_contract.py
  3. 2
      contract_show_invoice/__manifest__.py
  4. 12
      contract_show_invoice/models/account_analytic_account.py
  5. 13
      contract_show_invoice/views/contract_view.xml

2
contract/__manifest__.py

@ -9,7 +9,7 @@
{ {
'name': 'Contracts Management - Recurring', 'name': 'Contracts Management - Recurring',
'version': '10.0.4.3.0',
'version': '10.0.4.3.2',
'category': 'Contract Management', 'category': 'Contract Management',
'license': 'AGPL-3', 'license': 'AGPL-3',
'author': "OpenERP SA, " 'author': "OpenERP SA, "

3
contract/models/account_analytic_contract.py

@ -80,4 +80,5 @@ class AccountAnalyticContract(models.Model):
domain = [ domain = [
('type', '=', 'sale'), ('type', '=', 'sale'),
('company_id', '=', company_id)] ('company_id', '=', company_id)]
return self.env['account.journal'].search(domain, limit=1)
return self.env['account.journal'].search(
domain, order='sequence asc', limit=1)

2
contract_show_invoice/__manifest__.py

@ -6,7 +6,7 @@
{ {
'name': 'Contract Show Invoice', 'name': 'Contract Show Invoice',
'summary': 'Button in contracts to show their invoices', 'summary': 'Button in contracts to show their invoices',
'version': '10.0.1.0.1',
'version': '10.0.1.0.2',
'license': 'AGPL-3', 'license': 'AGPL-3',
'author': 'Domatix,' 'author': 'Domatix,'
'Tecnativa,' 'Tecnativa,'

12
contract_show_invoice/models/account_analytic_account.py

@ -10,13 +10,15 @@ class AccountAnalyticAccount(models.Model):
@api.multi @api.multi
def _compute_total_invoiced(self): def _compute_total_invoiced(self):
invoice_model = self.env['account.invoice']
invoice_line_model = self.env['account.invoice.line']
for analytic in self: for analytic in self:
fetch_data = invoice_model.read_group(
[('invoice_line_ids.account_analytic_id', '=', analytic.id)],
['amount_total'], [],
fetch_data = invoice_line_model.read_group(
[('account_analytic_id', '=', analytic.id),
('invoice_id.state', 'in', ['open', 'paid']),
('invoice_id.type', 'in', ['out_invoice', 'out_refund'])],
['price_subtotal_signed'], [],
) )
analytic.total_invoiced = fetch_data[0]['amount_total']
analytic.total_invoiced = fetch_data[0]['price_subtotal_signed']
total_invoiced = fields.Float(string="Total Invoiced", total_invoiced = fields.Float(string="Total Invoiced",
compute='_compute_total_invoiced') compute='_compute_total_invoiced')

13
contract_show_invoice/views/contract_view.xml

@ -6,7 +6,7 @@
[active_id], 'default_analytic_account_ids': [active_id]}</field> [active_id], 'default_analytic_account_ids': [active_id]}</field>
<field name="name">Invoices</field> <field name="name">Invoices</field>
<field name="res_model">account.invoice</field> <field name="res_model">account.invoice</field>
<field name="domain">[('analytic_account_ids','=',active_id)]</field>
<field name="domain">[('analytic_account_ids','=',active_id), ('type','in', ['out_invoice', 'out_refund']), ('state', 'not in', ['draft', 'cancel'])]</field>
<field name="search_view_id" ref="account.view_account_invoice_filter" /> <field name="search_view_id" ref="account.view_account_invoice_filter" />
</record> </record>
@ -24,6 +24,17 @@
<field name="act_window_id" ref="act_analytic_invoices"/> <field name="act_window_id" ref="act_analytic_invoices"/>
</record> </record>
<record id="invoice_tree_show_total_untaxed" model="ir.ui.view">
<field name="name">account.invoice.tree.show.total.untaxed</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_tree"/>
<field name="arch" type="xml">
<field name="amount_total_signed" position="after">
<field name="amount_untaxed_signed" sum="Total Untaxed"/>
</field>
</field>
</record>
<record id="account_analytic_account_button_invoice" model="ir.ui.view"> <record id="account_analytic_account_button_invoice" model="ir.ui.view">
<field name="name">account.analytic.account.button.invoice <field name="name">account.analytic.account.button.invoice
</field> </field>

Loading…
Cancel
Save