Skip to content

Commit

Permalink
[14.0][IMP] product_tier_validation state_to default values
Browse files Browse the repository at this point in the history
  • Loading branch information
Kev-Roche committed Feb 24, 2023
1 parent 179c8d3 commit f78f00d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion product_tier_validation/models/product_template.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
# Copyright 2021 Open Source Integrators
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, models
from odoo import api, models, tools
from odoo.exceptions import UserError

class ProductTemplate(models.Model):
_name = "product.template"
_inherit = ["product.template", "tier.validation"]
_tier_validation_manual_config = False

@property
@tools.ormcache()
def _state_to(self):
return (
self.env["product.state"]
.search([])
.filtered(
lambda x, s=self: x.code not in (s._state_from + [s._cancel_state])
)
.mapped("code")
)

def write(self, vals):
# Tier Validation does not work with Stages, only States :-(
# So, signal state transition by adding it to the vals
Expand Down

0 comments on commit f78f00d

Please sign in to comment.