Skip to content

[6926][ADD] purchase_order_analytic_account_from_lines - #154

Open
nobuQuartile wants to merge 2 commits into
16.0from
add-purchase_order_analytic_account
Open

[6926][ADD] purchase_order_analytic_account_from_lines#154
nobuQuartile wants to merge 2 commits into
16.0from
add-purchase_order_analytic_account

Conversation

@nobuQuartile

@nobuQuartile nobuQuartile commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

QT6926

Adds Analytic Accounts of Lines on the purchase order: the analytic accounts the lines of the order are distributed to, as an optional column of the purchase order list and as a filter of its search view.

The analytic distribution of a line is held in a json field, which cannot be shown as a column, grouped or filtered on. An order level distribution is no answer either, as it can only stand for the lines as long as every one of them is distributed the same way — it says nothing as soon as one line differs. The field holds the accounts of every line, whichever analytic plan they belong to, and it is stored, so the orders can be filtered by analytic account.

Split out of #153, which keeps the budget number of the order lines.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6db2c2d5f1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread purchase_order_analytic_account_from_lines/models/purchase_order.py
@nobuQuartile
nobuQuartile force-pushed the add-purchase_order_analytic_account branch from 6db2c2d to ed38aca Compare August 24, 2026 03:40
The analytic distribution of a purchase order line is held in a json field,
which cannot be shown as a column, grouped or filtered on. An order level
distribution is no answer either, as it can only stand for the lines as long
as every one of them is distributed the same way.

Hold the analytic accounts of the lines on the order itself, so what an order
is distributed to can be seen from the purchase order list whichever way its
lines are distributed. The accounts are shown as tags coloured by their
analytic plan, the way the analytic distribution itself is, and the search
view searches the orders by the name of an analytic account.
@nobuQuartile
nobuQuartile force-pushed the add-purchase_order_analytic_account branch from ed38aca to 5a38c30 Compare August 24, 2026 04:28

@yostashiro yostashiro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Partial review.

Comment thread purchase_order_analytic_account/__manifest__.py Outdated
class PurchaseOrder(models.Model):
_inherit = "purchase.order"

analytic_account_ids = fields.Many2many(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This field name clashes with the one from analytic_mixin_analytic_account. I think this one should be line_analycit_account_ids or something like that to better represent what it is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

"account.analytic.account",
string="Analytic Accounts of Lines",
compute="_compute_analytic_account_ids",
store=True,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we consider adding pre-init hook (+ server action to update existing records)?

@nobuQuartile nobuQuartile Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think we need either here.

line_analytic_account_ids is already filled for every existing purchase order at install time.

And installing it on Test took about 4 seconds, so recomputing isn't a practical concern at our data volume either.

@yostashiro

Copy link
Copy Markdown
Member

Maybe purchase_order_analytic_account_from_lines as the module name.

@AungKoKoLin1997 AungKoKoLin1997 left a comment

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.

I believe we don't need to add new field or add the logic. We can just made some adjustment in existing module purchase_view_adj. If you want to make it store, keep the current module but just add store attribute only to the field.
OCA/account-analytic#565 (comment)

@yostashiro

Copy link
Copy Markdown
Member

I believe we don't need to add new field or add the logic. We can just made some adjustment in existing module purchase_view_adj. If you want to make it store, keep the current module but just add store attribute only to the field. OCA/account-analytic#565 (comment)

@AungKoKoLin1997 I think you miss the point of taking analytic accounts from lines.

@nobuQuartile

Copy link
Copy Markdown
Contributor Author

Pushed d770b5c to add-purchase_order_analytic_account, addressing the three review comments.

1. depends — narrowed to ["purchase"]. analytic comes in transitively via purchaseaccountanalytic, so it does not need to be listed.

2. Field renameanalytic_account_idsline_analytic_account_ids, so it no longer collides with the field analytic_mixin_analytic_account adds to analytic.mixin, and the name now says that the accounts come from the lines. Updated across the model, views, tests and ja.po.

3. Module renamepurchase_order_analytic_accountpurchase_order_analytic_account_from_lines, including the setup/ directory and its symlink, the test module and class names, the view name attributes, the manifest name ("Purchase Order Analytic Account from Lines"), and the generated README.rst / static/description/index.html.

git show --stat d770b5c
 delete mode 100644 purchase_order_analytic_account/tests/__init__.py
 rename {purchase_order_analytic_account => purchase_order_analytic_account_from_lines}/README.rst (86%)
 rename {purchase_order_analytic_account => purchase_order_analytic_account_from_lines}/__init__.py (100%)
 rename {purchase_order_analytic_account => purchase_order_analytic_account_from_lines}/__manifest__.py (84%)
 rename {purchase_order_analytic_account => purchase_order_analytic_account_from_lines}/i18n/ja.po (70%)
 rename {purchase_order_analytic_account => purchase_order_analytic_account_from_lines}/models/__init__.py (100%)
 rename {purchase_order_analytic_account => purchase_order_analytic_account_from_lines}/models/purchase_order.py (88%)
 rename {purchase_order_analytic_account => purchase_order_analytic_account_from_lines}/readme/CONTRIBUTORS.md (100%)
 rename {purchase_order_analytic_account => purchase_order_analytic_account_from_lines}/readme/DESCRIPTION.md (100%)
 rename {purchase_order_analytic_account => purchase_order_analytic_account_from_lines}/static/description/index.html (95%)
 create mode 100644 purchase_order_analytic_account_from_lines/tests/__init__.py
 rename purchase_order_analytic_account/tests/test_purchase_order_analytic_account.py => purchase_order_analytic_account_from_lines/tests/test_purchase_order_analytic_account_from_lines.py (85%)
 rename {purchase_order_analytic_account => purchase_order_analytic_account_from_lines}/views/purchase_order_views.xml (82%)
 delete mode 120000 setup/purchase_order_analytic_account/odoo/addons/purchase_order_analytic_account
 create mode 120000 setup/purchase_order_analytic_account_from_lines/odoo/addons/purchase_order_analytic_account_from_lines
 rename setup/{purchase_order_analytic_account => purchase_order_analytic_account_from_lines}/setup.py (100%)

@nobuQuartile nobuQuartile changed the title [6926][ADD] purchase_order_analytic_account [6926][ADD] purchase_order_analytic_account_from_lines Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants