-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[16.0][FIX] sale_invoice_policy: compute qty to invoice
- Loading branch information
1 parent
9a9eaa2
commit 3aa5173
Showing
16 changed files
with
63 additions
and
249 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -7,7 +7,7 @@ Sale invoice Policy | |
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:3c1505e28f76dfda1fccdabb3cce63bab46df277823c4236d77da275a16a5a3c | ||
!! source digest: sha256:f7cef4d695f93f0893a61a5db0dc5ea532311d04314a81189214b7a49d43faed | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
|
@@ -70,6 +70,7 @@ Contributors | |
* Denis Roussel <[email protected]> | ||
* Alexei Rivera <[email protected]> | ||
* Luis J. Salvatierra <[email protected]> | ||
* Alejandro Ji Cheung <[email protected]> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
This file contains 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,2 +1 @@ | ||
from . import models | ||
from .post_init_hook import post_init_hook |
This file contains 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 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,54 +1,18 @@ | ||
# Copyright 2017 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 ProductTemplate(models.Model): | ||
_inherit = "product.template" | ||
|
||
default_invoice_policy = fields.Selection( | ||
[("order", "Ordered quantities"), ("delivery", "Delivered quantities")], | ||
string="Default Invoicing Policy", | ||
help="Ordered Quantity: Invoice based on the quantity the customer " | ||
"ordered.\n" | ||
"Delivered Quantity: Invoiced based on the quantity the vendor " | ||
"delivered (time or deliveries).", | ||
default=lambda self: self.env["ir.default"].get( | ||
"res.config.settings", "default_invoice_policy" | ||
), | ||
) | ||
def _default_invoice_policy(self): | ||
return ( | ||
self.env["res.config.settings"] | ||
.sudo() | ||
.default_get(["default_invoice_policy"]) | ||
.get("default_invoice_policy", False) | ||
) | ||
|
||
invoice_policy = fields.Selection( | ||
compute="_compute_invoice_policy", | ||
store=False, | ||
readonly=True, | ||
search="_search_invoice_policy", | ||
inverse="_inverse_invoice_policy", | ||
precompute=False, | ||
) | ||
|
||
def _inverse_invoice_policy(self): | ||
for template in self.filtered("invoice_policy"): | ||
template.default_invoice_policy = template.invoice_policy | ||
|
||
@api.depends("detailed_type", "default_invoice_policy") | ||
@api.depends_context("invoice_policy") | ||
def _compute_invoice_policy(self): | ||
""" | ||
Apply the invoice_policy given by context (if exist) otherwise use the | ||
default invoice policy given by the field with this same name. | ||
If the product is type = 'service', we don't have to apply the invoice | ||
policy given by the context. | ||
:return: | ||
""" | ||
invoice_policy = self.env.context.get("invoice_policy") | ||
for tmpl in self: | ||
if tmpl.type != "service" and invoice_policy: | ||
tmpl.invoice_policy = invoice_policy | ||
else: | ||
tmpl.invoice_policy = tmpl.default_invoice_policy | ||
|
||
@api.model | ||
def _search_invoice_policy(self, operator, value): | ||
return [("default_invoice_policy", operator, value)] | ||
invoice_policy = fields.Selection(default=_default_invoice_policy) |
This file contains 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 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 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 was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
* Denis Roussel <[email protected]> | ||
* Alexei Rivera <[email protected]> | ||
* Luis J. Salvatierra <[email protected]> | ||
* Alejandro Ji Cheung <[email protected]> |
This file contains 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
Oops, something went wrong.