Skip to content

Commit

Permalink
[FIX+IMP] analytic_partner:
Browse files Browse the repository at this point in the history
* IMP: Distinguish between the partner of the account and the specific partner
* FIX: Allow grouping on partner_id field. Fixes OCA#41
* FIX: README - Indentation is not correct in Known issues.
  • Loading branch information
pedrobaeza authored and dreispt committed Nov 18, 2023
1 parent 9a776e6 commit 564b7be
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 12 deletions.
2 changes: 1 addition & 1 deletion analytic_partner/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Known issues / Roadmap
======================

* This module hasn't been tested with *account_analytic_plans* module
installed, so maybe it's incompatible with it.
installed, so maybe it's incompatible with it.

Credits
=======
Expand Down
8 changes: 7 additions & 1 deletion analytic_partner/i18n/analytic_partner.pot
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ msgstr ""
msgid "Costs & Revenues"
msgstr ""

#. module: analytic_partner
#: view:account.analytic.line:analytic_partner.view_account_analytic_line_filter_partner
#: field:account.analytic.line,other_partner_id:0
msgid "Other Partner"
msgstr ""

#. module: analytic_partner
#: view:account.analytic.line:analytic_partner.view_account_analytic_line_filter_partner
#: field:account.analytic.line,partner_id:0
msgid "Partner"
msgid "Account Partner"
msgstr ""

10 changes: 8 additions & 2 deletions analytic_partner/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ msgstr "Costes/Ingresos"
msgid "Costs & Revenues"
msgstr "Costes e ingresos"

#. module: analytic_partner
#: view:account.analytic.line:analytic_partner.view_account_analytic_line_filter_partner
#: field:account.analytic.line,other_partner_id:0
msgid "Other Partner"
msgstr "Empresa alternativa"

#. module: analytic_partner
#: view:account.analytic.line:analytic_partner.view_account_analytic_line_filter_partner
#: field:account.analytic.line,partner_id:0
msgid "Partner"
msgstr "Empresa"
msgid "Account Partner"
msgstr "Empresa de la cuenta"

7 changes: 5 additions & 2 deletions analytic_partner/models/account_analytic_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ class AccountAnalyticLine(models.Model):
_inherit = 'account.analytic.line'

partner_id = fields.Many2one(
comodel_name='res.partner', string="Partner",
domain="[('parent_id', '=', False)]")
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)]")
2 changes: 1 addition & 1 deletion analytic_partner/models/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ def _get_analytic_lines(self):
iml = super(AccountInvoice, self)._get_analytic_lines()
for il in iml:
for analytic_vals in il.get('analytic_lines', []):
analytic_vals[2]['partner_id'] = (
analytic_vals[2]['other_partner_id'] = (
self.partner_id.commercial_partner_id.id)
return iml
2 changes: 1 addition & 1 deletion analytic_partner/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ class AccountMoveLine(models.Model):
@api.model
def _prepare_analytic_line(self, obj_line):
res = super(AccountMoveLine, self)._prepare_analytic_line(obj_line)
res['partner_id'] = (
res['other_partner_id'] = (
obj_line.invoice.partner_id.commercial_partner_id.id)
return res
2 changes: 1 addition & 1 deletion analytic_partner/tests/test_analytic_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ def test_partner_from_invoice(self):
analytic_lines = self.invoice.move_id.mapped('line_id.analytic_lines')
for analytic_line in analytic_lines:
self.assertEqual(
analytic_line.partner_id,
analytic_line.other_partner_id,
self.invoice.partner_id.commercial_partner_id,
'Invoice partner has not been propagated to the analytic line')
5 changes: 4 additions & 1 deletion analytic_partner/views/account_analytic_line_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<field name="arch" type="xml">
<field name="journal_id" position="after">
<field name="partner_id"/>
<field name="other_partner_id"/>
</field>
</field>
</record>
Expand All @@ -20,6 +21,7 @@
<field name="arch" type="xml">
<field name="ref" position="after">
<field name="partner_id"/>
<field name="other_partner_id"/>
</field>
</field>
</record>
Expand All @@ -30,7 +32,8 @@
<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_partner" string="Partner" context="{'group_by': 'partner_id'}"/>
<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>
Expand Down
4 changes: 2 additions & 2 deletions analytic_partner/views/res_partner_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<data>

<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_partner_id': active_id}</field>
<field name="domain">[('partner_id', 'child_of', active_id)]</field>
<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 &amp; Revenues</field>
<field name="res_model">account.analytic.line</field>
<field name="src_model">res.partner</field>
Expand Down

0 comments on commit 564b7be

Please sign in to comment.