-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[IMP] sale_invoice_policy: Several improvements #3376
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
Merged
OCA-git-bot
merged 8 commits into
OCA:16.0
from
acsone:16.0-imp-sale-invoice-policy-dro
Mar 17, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8a40dc7
[FIX] sale_invoice_policy: Don't use the 'required' parameter
rousseldenis 313e774
[IMP] sale_invoice_policy: Don't reuse fields in depends
rousseldenis d35adc8
[IMP] sale_invoice_policy: Don't rely on required option to compute t…
rousseldenis 3d83c3d
[IMP] sale_invoice_policy: Don't rewrite Odoo core compute method
rousseldenis cd4155c
[IMP] sale_invoice_policy: save products invoice policy values in a s…
rousseldenis 7d48884
[IMP] sale_invoice_policy: Add the default behavior as sale invoice p…
rousseldenis ea5fcb9
[IMP] sale_invoice_policy: Use protecting() instead of deprecated nor…
rousseldenis f707990
[IMP] sale_invoice_policy: Improve README
rousseldenis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| # generated from manifests external_dependencies | ||
| openupgradelib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| from .hooks import pre_init_hook | ||
| from . import models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Copyright 2024 ACSONE SA/NV (<https://acsone.eu>) | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
| from openupgradelib import openupgrade | ||
|
|
||
| from odoo.api import SUPERUSER_ID, Environment | ||
|
|
||
|
|
||
| def pre_init_hook(cr): | ||
| """ | ||
| Create the sale order invoice policy with the "product" policy (standard) | ||
| but with a postgres query to avoid an update on all sale order records | ||
| """ | ||
| env = Environment(cr, SUPERUSER_ID, {}) | ||
| field_spec = [ | ||
| ( | ||
| "invoice_policy", | ||
| "sale.order", | ||
| False, | ||
| "selection", | ||
| False, | ||
| "sale_invoice_policy", | ||
| "product", | ||
| ) | ||
| ] | ||
| openupgrade.add_fields(env, field_spec=field_spec) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| from . import res_config_settings | ||
| from . import sale_order | ||
| from . import sale_order_line | ||
| from . import res_company |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Copyright 2024 ACSONE SA/NV (<https://acsone.eu>) | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
|
||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class ResCompany(models.Model): | ||
|
|
||
| _inherit = "res.company" | ||
|
|
||
| sale_default_invoice_policy = fields.Selection( | ||
| [ | ||
| ("product", "Products Invoice Policy"), | ||
| ("order", "Ordered quantities"), | ||
| ("delivery", "Delivered quantities"), | ||
| ], | ||
| default="product", | ||
| required=True, | ||
| help="This will be the default invoice policy for sale orders.", | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,13 @@ | ||
| # Copyright 2018 ACSONE SA/NV (<http://acsone.eu>) | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
|
||
| from odoo import api, fields, models | ||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class ResConfigSettings(models.TransientModel): | ||
| _inherit = "res.config.settings" | ||
|
|
||
| sale_invoice_policy_required = fields.Boolean( | ||
| help="This makes Invoice Policy required on Sale Orders" | ||
| sale_default_invoice_policy = fields.Selection( | ||
| related="company_id.sale_default_invoice_policy", | ||
| readonly=False, | ||
| ) | ||
|
|
||
| @api.model | ||
| def get_values(self): | ||
| res = super().get_values() | ||
| res.update( | ||
| sale_invoice_policy_required=self.env["ir.default"].get( | ||
| "res.config.settings", "sale_invoice_policy_required" | ||
| ) | ||
| ) | ||
| return res | ||
|
|
||
| def set_values(self): | ||
| super().set_values() | ||
| ir_default_obj = self.env["ir.default"] | ||
| if self.env["res.users"].has_group("base.group_erp_manager"): | ||
| ir_default_obj = ir_default_obj.sudo() | ||
| ir_default_obj.set( | ||
| "res.config.settings", | ||
| "sale_invoice_policy_required", | ||
| self.sale_invoice_policy_required, | ||
| ) | ||
| return True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| * Go to Sale > Configuration > Settings > Sale Invoice Policy | ||
| * Choose the one that fits your needs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| In Odoo, products have their own invoicing policy that can be: | ||
|
|
||
| - Invoicing on ordered quantities | ||
| - Invoicing on ordered quantities | ||
|
|
||
| Following that configuration, when trying to create invoices from | ||
| sale orders, each line of product will apply its invoicing policy. | ||
|
|
||
| In some cases, user needs to apply an invoicing policy on a whole | ||
| sale order. | ||
|
|
||
| The solution proposed here is to add an invoicing policy on | ||
| sale order level. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.