Skip to content

Conversation

@jcoux
Copy link

@jcoux jcoux commented Dec 5, 2025

No description provided.

TDu and others added 13 commits December 5, 2025 09:04
Description from the readme :

When invoicing multiple sale orders at the same time, sale orders may be grouped
by customer into a single invoice. Unfortunately when this happens, it is hard
to know which invoice line belongs to which sale order.

This module helps by grouping invoicing lines into sections with the name of the
targeted sale order.
This is only done when an invoice targets multiple sale order.
The function signature as changed in v14
[UPD] Update account_invoice_section_sale_order.pot

[UPD] README.rst
Translated using Weblate (Spanish)

Currently translated at 100.0% (1 of 1 strings)

Translation: account-invoicing-16.0/account-invoicing-16.0-account_invoice_section_sale_order
Translate-URL: https://translation.odoo-community.org/projects/account-invoicing-16-0/account-invoicing-16-0-account_invoice_section_sale_order/es/
@jcoux jcoux mentioned this pull request Dec 5, 2025
38 tasks
mymage and others added 13 commits December 5, 2025 09:09
Refactor preparation of sections

Refactor to allow different section grouping

Add field to allow different possibilities of grouping invoice lines from sale order
…on tests

In OCA repo, now we have this error:

 Traceback (most recent call last):
  File "/__w/account-invoicing/account-invoicing/account_invoice_section_sale_order/tests/test_invoice_group_by_sale_order.py", line 109, in test_create_invoice
    self.assertEqual(line.name, result[line.sequence][0])
KeyError: 1
Currently translated at 100.0% (18 of 18 strings)

Translation: account-invoicing-17.0/account-invoicing-17.0-account_invoice_section_sale_order
Translate-URL: https://translation.odoo-community.org/projects/account-invoicing-17-0/account-invoicing-17-0-account_invoice_section_sale_order/it/
the `sale.order._create_invoices() method does not only requires
`create` access to the `account.move` and `account.move.line` models.

Because we're actually sorting lines after the creating, it requires
`read` access to sort, and `write` access to modify their sequence.

This is problematic when interracting with other modules like
`invoice_mode_at_shipping` where stock users are the ones to create
invoices.

This commit adds a few `sudo()` in the code, in order to avoid granting
`read` and `write` access to users that shouldn't be allowed to read and write invoices.
@jcoux jcoux force-pushed the 19.0-mig-account_invoice_section_sale_order branch from 81d353b to 0fccec7 Compare December 5, 2025 08:10
@jcoux jcoux force-pushed the 19.0-mig-account_invoice_section_sale_order branch from 663b2e9 to dd00400 Compare December 5, 2025 11:17
@jcoux jcoux marked this pull request as ready for review December 5, 2025 14:25
Copy link
Contributor

@luisDIXMIT luisDIXMIT left a comment

Choose a reason for hiding this comment

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

Tested on runboat and LGTM! As an improvement, the explanation of the grouping name expression should be more detailed about how it must be set or validated more strictly in order to avoid this error (I set the string "Group" in the naming scheme).

Odoo Server Error

Occured on oca-account-invoicing-19-0-pr2185-dd0040017254.runboat.odoo-community.org on model sale.advance.payment.inv on 2025-12-09 07:27:17 GMT

Traceback (most recent call last):
File "/opt/odoo/odoo/tools/safe_eval.py", line 397, in safe_eval
return unsafe_eval(c, globals_dict, None)
File "", line 1, in
NameError: name 'Group' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/odoo/odoo/http.py", line 2275, in _serve_db
return service_model.retrying(serve_func, env=self.env)
File "/opt/odoo/odoo/service/model.py", line 184, in retrying
result = func()
File "/opt/odoo/odoo/http.py", line 2330, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
File "/opt/odoo/odoo/http.py", line 2545, in dispatch
result = self.request.registry['ir.http']._dispatch(endpoint)
File "/opt/odoo/odoo/addons/base/models/ir_http.py", line 355, in _dispatch
result = endpoint(**request.params)
File "/opt/odoo/odoo/http.py", line 788, in route_wrapper
result = endpoint(self, *args, **params_ok)
File "/opt/odoo/addons/web/controllers/dataset.py", line 38, in call_button
action = call_kw(request.env[model], method, args, kwargs)
File "/opt/odoo/odoo/service/model.py", line 93, in call_kw
result = method(recs, *args, **kwargs)
File "/opt/odoo/addons/sale/wizard/sale_make_invoice_advance.py", line 123, in create_invoices
invoices = self._create_invoices(self.sale_order_ids)
File "/opt/odoo/addons/sale/wizard/sale_make_invoice_advance.py", line 141, in _create_invoices
return sale_orders._create_invoices(final=self.deduct_down_payments, grouped=not self.consolidated_billing)
File "/mnt/data/odoo-addons-dir/account_invoice_section_sale_order/models/sale_order.py", line 43, in _create_invoices
"name": group._get_invoice_section_name(),
File "/mnt/data/odoo-addons-dir/account_invoice_section_sale_order/models/sale_order.py", line 79, in _get_invoice_section_name
return safe_eval(naming_scheme, {"object": self, "time": time})
File "/opt/odoo/odoo/tools/safe_eval.py", line 403, in safe_eval
raise ValueError('%r while evaluating\n%r' % (e, expr))
ValueError: NameError("name 'Group' is not defined") while evaluating
'Group'

The above server error caused the following client error:
RPC_ERROR: Odoo Server Error
RPC_ERROR
at makeErrorFromResponse (http://oca-account-invoicing-19-0-pr2185-dd0040017254.runboat.odoo-community.org/web/assets/a683405/web.assets_web.min.js:3186:165)
at XMLHttpRequest. (http://oca-account-invoicing-19-0-pr2185-dd0040017254.runboat.odoo-community.org/web/assets/a683405/web.assets_web.min.js:3192:13)

Copy link

@yankinmax yankinmax left a comment

Choose a reason for hiding this comment

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

Technical review

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.