Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] analytic_account: Migrated to 10.0
- Loading branch information
1 parent
e25a3a3
commit c9d2b17
Showing
9 changed files
with
144 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2015 Pedro M. Baeza | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
from openerp import models, fields | ||
from odoo import fields, models | ||
|
||
|
||
class AccountAnalyticLine(models.Model): | ||
_inherit = 'account.analytic.line' | ||
|
||
partner_id = fields.Many2one( | ||
comodel_name='res.partner', string="Account Partner", | ||
related="account_id.partner_id", readonly=True, store=True) | ||
other_partner_id = fields.Many2one( | ||
comodel_name='res.partner', string="Other Partner", | ||
domain="['|', ('parent_id', '=', False), ('is_company', '=', True)]") |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2015 Pedro M. Baeza | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
from openerp import models, api | ||
from odoo import api, models | ||
|
||
|
||
class AccountMoveLine(models.Model): | ||
_inherit = 'account.move.line' | ||
|
||
@api.model | ||
def _prepare_analytic_line(self, obj_line): | ||
res = super(AccountMoveLine, self)._prepare_analytic_line(obj_line) | ||
res['other_partner_id'] = ( | ||
obj_line.invoice.partner_id.commercial_partner_id.id) | ||
@api.multi | ||
def _prepare_analytic_line(self): | ||
res = super(AccountMoveLine, self)._prepare_analytic_line() | ||
res[0]['other_partner_id'] = \ | ||
self.invoice_id.partner_id.commercial_partner_id.id | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,49 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2015 Pedro M. Baeza | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
import openerp.tests.common as common | ||
from openerp import workflow | ||
import odoo.tests.common as common | ||
|
||
|
||
class TestAnalyticPartner(common.TransactionCase): | ||
class TestAnalyticPartner(common.SavepointCase): | ||
|
||
def setUp(self): | ||
super(TestAnalyticPartner, self).setUp() | ||
product = self.env.ref('product.product_product_5') | ||
self.analytic_account = self.env['account.analytic.account'].create( | ||
{'name': 'Test Analytic Account', | ||
'state': 'draft', | ||
'type': 'normal'} | ||
) | ||
self.invoice = self.env['account.invoice'].create( | ||
{'journal_id': self.env.ref('account.sales_journal').id, | ||
'partner_id': self.env.ref('base.res_partner_3').id, | ||
'account_id': self.env.ref('account.a_recv').id, | ||
'invoice_line': [ | ||
(0, 0, {'product_id': product.id, | ||
'name': 'Test', | ||
'account_analytic_id': self.analytic_account.id, | ||
'quantity': 10.0, | ||
})], | ||
}) | ||
workflow.trg_validate(self.uid, 'account.invoice', self.invoice.id, | ||
'invoice_open', self.cr) | ||
@classmethod | ||
def setUpClass(cls): | ||
super(TestAnalyticPartner, cls).setUpClass() | ||
cls.partner = cls.env['res.partner'].create({ | ||
'name': 'Test partner', | ||
}) | ||
cls.account_type = cls.env['account.account.type'].create({ | ||
'name': 'Test account type', | ||
'type': 'other', | ||
}) | ||
cls.account = cls.env['account.account'].create({ | ||
'name': 'Test account', | ||
'code': 'TEST', | ||
'user_type_id': cls.account_type.id | ||
}) | ||
cls.analytic_account = cls.env['account.analytic.account'].create({ | ||
'name': 'Test Analytic Account', | ||
}) | ||
cls.invoice = cls.env['account.invoice'].create({ | ||
'partner_id': cls.partner.id, | ||
'invoice_line_ids': [ | ||
(0, 0, { | ||
'name': 'Test line', | ||
'account_id': cls.account.id, | ||
'account_analytic_id': cls.analytic_account.id, | ||
'quantity': 10.0, | ||
'price_unit': 50.0, | ||
}) | ||
] | ||
}) | ||
|
||
def test_partner_from_invoice(self): | ||
analytic_lines = self.invoice.move_id.mapped('line_id.analytic_lines') | ||
def test_flow(self): | ||
self.invoice.action_invoice_open() | ||
analytic_lines = self.invoice.move_id.mapped( | ||
'line_ids.analytic_line_ids') | ||
for analytic_line in analytic_lines: | ||
self.assertEqual( | ||
analytic_line.other_partner_id, | ||
self.invoice.partner_id.commercial_partner_id, | ||
'Invoice partner has not been propagated to the analytic line') | ||
'''Invoice partner has not been propagated | ||
to the analytic line''') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
<odoo> | ||
|
||
<record model="ir.ui.view" id="view_account_analytic_line_tree_partner"> | ||
<field name="name">Analytic entries tree (with partner)</field> | ||
<field name="model">account.analytic.line</field> | ||
<field name="inherit_id" ref="account.view_account_analytic_line_tree" /> | ||
<field name="arch" type="xml"> | ||
<field name="journal_id" position="after"> | ||
<field name="partner_id"/> | ||
<field name="other_partner_id"/> | ||
</field> | ||
<record model="ir.ui.view" id="view_account_analytic_line_tree"> | ||
<field name="name">Analytic entries tree (with partner)</field> | ||
<field name="model">account.analytic.line</field> | ||
<field name="inherit_id" | ||
ref="analytic.view_account_analytic_line_tree" /> | ||
<field name="arch" type="xml"> | ||
<field name="account_id" position="after"> | ||
<field name="partner_id"/> | ||
<field name="other_partner_id"/> | ||
</field> | ||
</record> | ||
</field> | ||
</record> | ||
|
||
<record model="ir.ui.view" id="view_account_analytic_line_form_partner"> | ||
<field name="name">Analytic entries form (with partner)</field> | ||
<field name="model">account.analytic.line</field> | ||
<field name="inherit_id" ref="account.view_account_analytic_line_form" /> | ||
<field name="arch" type="xml"> | ||
<field name="ref" position="after"> | ||
<field name="partner_id"/> | ||
<field name="other_partner_id"/> | ||
</field> | ||
<record model="ir.ui.view" id="view_account_analytic_line_form"> | ||
<field name="name">Analytic entries form (with partner)</field> | ||
<field name="model">account.analytic.line</field> | ||
<field name="inherit_id" | ||
ref="analytic.view_account_analytic_line_form" /> | ||
<field name="arch" type="xml"> | ||
<field name="account_id" position="after"> | ||
<field name="other_partner_id"/> | ||
</field> | ||
</record> | ||
</field> | ||
</record> | ||
|
||
<record model="ir.ui.view" id="view_account_analytic_line_filter_partner"> | ||
<field name="name">Analytic entries search (with partner)</field> | ||
<field name="model">account.analytic.line</field> | ||
<field name="inherit_id" ref="account.view_account_analytic_line_filter" /> | ||
<field name="arch" type="xml"> | ||
<filter name="group_journal" position="after"> | ||
<filter name="group_account_partner" string="Account Partner" context="{'group_by': 'partner_id'}"/> | ||
<filter name="group_partner" string="Other Partner" context="{'group_by': 'other_partner_id'}"/> | ||
</filter> | ||
</field> | ||
</record> | ||
<record model="ir.ui.view" id="view_account_analytic_line_filter"> | ||
<field name="name">Analytic entries search (with partner)</field> | ||
<field name="model">account.analytic.line</field> | ||
<field name="inherit_id" | ||
ref="analytic.view_account_analytic_line_filter" /> | ||
<field name="arch" type="xml"> | ||
<filter name="group_date" position="after"> | ||
<filter name="group_other_partner" string="Other Partner" | ||
context="{'group_by': 'other_partner_id'}"/> | ||
</filter> | ||
</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
<odoo> | ||
|
||
<record model="ir.actions.act_window" id="act_analytic_cost_revenue"> | ||
<field name="context">{'search_default_group_date': 1, 'search_default_group_journal': 1, 'default_other_partner_id': active_id}</field> | ||
<field name="domain">[('other_partner_id', 'child_of', active_id)]</field> | ||
<field name="name">Costs & Revenues</field> | ||
<field name="res_model">account.analytic.line</field> | ||
<field name="src_model">res.partner</field> | ||
<field name="view_mode">tree,form</field> | ||
<field name="view_type">form</field> | ||
</record> | ||
<record model="ir.actions.act_window" id="act_analytic_cost_revenue"> | ||
|
||
<record id="view_partner_form_analytic" model="ir.ui.view"> | ||
<field name="name">res.partner.form.analytic</field> | ||
<field name="model">res.partner</field> | ||
<field name="inherit_id" ref="base.view_partner_form"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr='//div[@name="buttons"]' position='inside'> | ||
<button class="oe_inline oe_stat_button" | ||
type="action" | ||
name="%(act_analytic_cost_revenue)d" | ||
icon="fa-usd" string="Cost/Revenue" widget="statinfo"/> | ||
</xpath> | ||
</field> | ||
</record> | ||
<field name="context">{'search_default_group_date': 1}</field> | ||
<field name="domain">[('other_partner_id', 'child_of', active_id)]</field> | ||
<field name="name">Costs & Revenues</field> | ||
<field name="res_model">account.analytic.line</field> | ||
<field name="src_model">res.partner</field> | ||
<field name="view_mode">tree,form</field> | ||
<field name="view_type">form</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> | ||
<record id="view_partner_form_analytic" model="ir.ui.view"> | ||
<field name="name">res.partner.form.analytic</field> | ||
<field name="model">res.partner</field> | ||
<field name="inherit_id" ref="base.view_partner_form"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr='//div[@name="button_box"]' position='inside'> | ||
<button class="oe_inline oe_stat_button" | ||
type="action" | ||
name="%(act_analytic_cost_revenue)d" | ||
icon="fa-usd" string="Cost/Revenue" widget="statinfo"/> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</odoo> |