Skip to content

[18.0][ADD] account_move_analytic: Analytic distribution at invoice and bill level#864

Open
JoanSForgeFlow wants to merge 4 commits intoOCA:18.0from
ForgeFlow:18.0-add-account_move_analytic
Open

[18.0][ADD] account_move_analytic: Analytic distribution at invoice and bill level#864
JoanSForgeFlow wants to merge 4 commits intoOCA:18.0from
ForgeFlow:18.0-add-account_move_analytic

Conversation

@JoanSForgeFlow
Copy link
Copy Markdown

Adds analytic distribution support on invoices and vendor bills by syncing the analytic distribution with the invoice lines.

/>
</field>
<field name="invoice_line_ids" position="attributes">
<attribute name="context" operation="update">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why, But I get an error when installing it on runboat

`Invalid attributes 'operation' in element

View error context:
{'file': '/mnt/data/odoo-addons-dir/account_move_analytic/views/account_move_views.xml',
'line': 1,
'name': 'account.move.form - Account Move Analytic',
'view': ir.ui.view(886,),
'view.model': 'account.move',
'view.parent': ir.ui.view(682,),
'xmlid': 'view_move_form_analytic'}`

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is missing base_view_inheritance_extension dependency, Thank you @AaronHForgeFlow

@JoanSForgeFlow JoanSForgeFlow force-pushed the 18.0-add-account_move_analytic branch from 24df8ca to 193e1d2 Compare January 14, 2026 12:34
Copy link
Copy Markdown
Contributor

@AaronHForgeFlow AaronHForgeFlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional review 👍

)

@api.onchange("analytic_distribution")
def _onchange_analytic_distribution(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JoanSForgeFlow analytic_distribution on lines is a stored field. Why not overriding compute method instead ?

break
move.analytic_distribution = first_distribution

def _inverse_analytic_distribution(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as here under

@JoanSForgeFlow JoanSForgeFlow force-pushed the 18.0-add-account_move_analytic branch 3 times, most recently from 56f3b26 to 43cb47a Compare January 26, 2026 11:43
@JoanSForgeFlow JoanSForgeFlow force-pushed the 18.0-add-account_move_analytic branch from 43cb47a to 723990a Compare January 26, 2026 11:47
@JoanSForgeFlow
Copy link
Copy Markdown
Author

Hi @rousseldenis:

Thanks for the feedback! I've refactored the code:

  • Removed the onchange method.
  • Added _related_analytic_distribution() override on account.move.line
  • Added move_id.analytic_distribution as a dependency to trigger line recomputation.

The inverse method is kept because it's required for the field to be editable - without it, changes wouldn't persist to the lines on save.

Let me know if this looks good. Thank you!

Copy link
Copy Markdown
Contributor

@rousseldenis rousseldenis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

lambda ln: ln.display_type not in ("line_section", "line_note")
)
if product_lines:
first_distribution = product_lines[0].analytic_distribution or False
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, Odoo uses first() on a recordset until v18, and then, they recommend to use next(iter())

@rousseldenis
Copy link
Copy Markdown
Contributor

@JoanSForgeFlow Ideally, an init script could be great as account moves amount on existing databases can be huge.

@@ -1,3 +1,6 @@
[project]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JoanSForgeFlow You should not have this entry at all here. Could you remove it ?

rousseldenis and others added 3 commits February 12, 2026 10:44
[FIX] account_move_analytic: Remove unwanted entry in pyproject.toml
Co-authored-by: Denis Roussel (ACSONE) <rousseldenis@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants