Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] sale_invoice_policy: Several improvements #3376

Open
wants to merge 8 commits into
base: 16.0
Choose a base branch
from

Conversation

rousseldenis
Copy link
Contributor

@rousseldenis rousseldenis commented Oct 24, 2024

  • Don't use the required parameter to compute the quantity to invoice
  • Simplify depends()
  • Don't use the required parameter to compute the untaxed amount to invoice
  • Don't rewrite the Odoo core compute method
  • Improve README

Refactor:

I think the default policy that was applied on sale orders from the default product configuration (defined in sale module) was the wrong approach as it is not contextually correct (products are not sale orders).

That said, I introduced an invoice policy on sale order level more explicitly than before (void) which is 'Products Invoicing Policy'. That let the user free to choose between standard behavior or sale order level configuration.

The question is:

Don't use the 'required' parameter to compute the quantities to invoice or not.
In fact, this should only depends on the invoice policy itself.
As ORM appends new depends() parameters to existing ones, simplify the writing
@rousseldenis rousseldenis force-pushed the 16.0-imp-sale-invoice-policy-dro branch from fb39a75 to 7b26e33 Compare October 24, 2024 11:00
…he amount

As for the 'qty_to_invoice' field, the 'untaxed_amount_to_invoice' field should not
depends on the required option to compute its value
As we don't want to rewrite Odoo core method inside this module, we
should not rewrite the method to compute the untaxed amount to invoice.

Instead, save the product invoice policy, change it to sale order one without
recomputing context, call the super() method and then, restore its former value.
@rousseldenis rousseldenis added this to the 16.0 milestone Oct 24, 2024
…olicy

With default behavior in Odoo, the invoicing policy depends on products configuration.
So, include this as possible value for sale order invoicing policy. Possible values are so:

  - Products Invoice Policy: each product applies its invoicing policy (by sale line)
  - Ordered quantities: the whole sale order will apply the invoicing policy on ordered quantities
  - Delivered Quantities: the whole sale order will apply the invoicing policy on delivered quantities

That said, the 'required' configuration is no more useful as the invoicing policy is now required
on sale order level.
@rousseldenis
Copy link
Contributor Author

Don't hesitate to test it on runboat

@rousseldenis rousseldenis force-pushed the 16.0-imp-sale-invoice-policy-dro branch from 655eb48 to f4ea1a1 Compare October 25, 2024 08:13
…ecompute()

To avoid marking 'invoice_policy' product field as dirty for products temporary value,
use the working context manager 'protecting()' instead of deprecated 'norecompute() one.

Put the whole process in its own contextmanager.
@rousseldenis rousseldenis force-pushed the 16.0-imp-sale-invoice-policy-dro branch from f4ea1a1 to dd6f488 Compare October 25, 2024 13:19
@rousseldenis rousseldenis marked this pull request as ready for review October 25, 2024 16:03
Copy link
Contributor

@ferran-S73 ferran-S73 left a comment

Choose a reason for hiding this comment

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

Code review OK. As per your question I see no problem in allowing product configuration for sale orders' invoice policy. It adds more flexibility to the module

Copy link

@phschmidt phschmidt left a comment

Choose a reason for hiding this comment

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

Functionary review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants