forked from OCA/sale-workflow
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] sale_invoice_policy: changes after OCA review
- Loading branch information
1 parent
66ebadd
commit 4b727ed
Showing
3 changed files
with
29 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +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, models | ||
from odoo import fields, models | ||
|
||
|
||
class ProductTemplate(models.Model): | ||
_inherit = "product.template" | ||
|
||
@api.depends("detailed_type") | ||
def _compute_invoice_policy(self): | ||
""" | ||
Apply the invoice_policy given by context (if exist) otherwise use the | ||
default invoice policy given by variable with this same name. | ||
If the product is type = 'service', we don't have to apply the invoice | ||
policy given by the context. | ||
""" | ||
invoice_policy = self.env.context.get("invoice_policy") | ||
if invoice_policy: | ||
non_service_products = self.filtered(lambda p: p.type != "service") | ||
non_service_products.invoice_policy = invoice_policy | ||
else: | ||
default_invoice_policy = ( | ||
self.env["res.config.settings"] | ||
.sudo() | ||
.default_get(["default_invoice_policy"]) | ||
.get("default_invoice_policy", False) | ||
) | ||
self.invoice_policy = 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(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