Skip to content

Commit

Permalink
[IMP] account_reconcile_analytic_tag: Add analytic tags to reconcilia…
Browse files Browse the repository at this point in the history
…tion model lines

TT51885
  • Loading branch information
victoralmau committed Nov 29, 2024
1 parent 2a6626c commit aba08e3
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 7 deletions.
1 change: 1 addition & 0 deletions account_reconcile_analytic_tag/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
"maintainers": ["victoralmau"],
"data": [
"views/account_bank_statement_line_views.xml",
"views/account_reconcile_model_views.xml",
],
}
1 change: 1 addition & 0 deletions account_reconcile_analytic_tag/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import account_reconcile_abstract
from . import account_bank_statement_line
from . import account_reconcile_model
47 changes: 47 additions & 0 deletions account_reconcile_analytic_tag/models/account_reconcile_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
from odoo import fields, models


class AccountReconcileModel(models.Model):
_inherit = "account.reconcile.model"

# TODO: Remove if merging https://github.com/odoo/odoo/pull/188808
def _get_write_off_move_lines_dict(self, residual_balance, partner_id):
res = super()._get_write_off_move_lines_dict(
residual_balance=residual_balance, partner_id=partner_id
)
if len(res) == 0:
return res

Check warning on line 15 in account_reconcile_analytic_tag/models/account_reconcile_model.py

View check run for this annotation

Codecov / codecov/patch

account_reconcile_analytic_tag/models/account_reconcile_model.py#L15

Added line #L15 was not covered by tests
currency = self.company_id.currency_id
for index, line in enumerate(self.line_ids):
if line.amount_type == "percentage":
balance = currency.round(residual_balance * (line.amount / 100.0))
elif line.amount_type == "fixed":
balance = currency.round(

Check warning on line 21 in account_reconcile_analytic_tag/models/account_reconcile_model.py

View check run for this annotation

Codecov / codecov/patch

account_reconcile_analytic_tag/models/account_reconcile_model.py#L21

Added line #L21 was not covered by tests
line.amount * (1 if residual_balance > 0.0 else -1)
)
else:
balance = 0.0

Check warning on line 25 in account_reconcile_analytic_tag/models/account_reconcile_model.py

View check run for this annotation

Codecov / codecov/patch

account_reconcile_analytic_tag/models/account_reconcile_model.py#L25

Added line #L25 was not covered by tests

if currency.is_zero(balance):
continue

Check warning on line 28 in account_reconcile_analytic_tag/models/account_reconcile_model.py

View check run for this annotation

Codecov / codecov/patch

account_reconcile_analytic_tag/models/account_reconcile_model.py#L28

Added line #L28 was not covered by tests

res[index]["manual_analytic_tag_ids"] = [(6, 0, line.analytic_tag_ids.ids)]
return res


class AccountReconcileModelLine(models.Model):
_inherit = "account.reconcile.model.line"

analytic_tag_ids = fields.Many2many(
comodel_name="account.analytic.tag",
string="Analytic Tags",
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]",
)

# TODO: Use if merging https://github.com/odoo/odoo/pull/188808
# def _get_write_off_move_line_dict(self, balance):
# vals = super()._get_write_off_move_line_dict(balance)
# vals["manual_analytic_tag_ids"] = [(6, 0, self.analytic_tag_ids.ids)]
# return vals
11 changes: 4 additions & 7 deletions account_reconcile_analytic_tag/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +274,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: gray; } /* line numbers */
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +300,7 @@
span.pre {
white-space: pre }

span.problematic, pre.problematic {
span.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -410,9 +409,7 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_account_reconcile_model_form" model="ir.ui.view">
<field name="name">account.reconcile.model.form</field>
<field name="model">account.reconcile.model</field>
<field name="inherit_id" ref="account.view_account_reconcile_model_form" />
<field name="arch" type="xml">
<xpath
expr="//field[@name='line_ids']/tree//field[@name='label']"
position="after"
>
<field
name="analytic_tag_ids"
groups="account_analytic_tag.group_analytic_tags"
widget="many2many_tags"
optional="hide"
options="{'color_field': 'color'}"
/>
</xpath>
</field>
</record>
</odoo>

0 comments on commit aba08e3

Please sign in to comment.