changeset 4ef5f97efe0e in modules/product:default
details: https://hg.tryton.org/modules/product?cmd=changeset&node=4ef5f97efe0e
description:
Add domain to cost_price_method depending of type
issue9720
diffstat:
CHANGELOG | 2 ++
product.py | 12 +++++++++++-
2 files changed, 13 insertions(+), 1 deletions(-)
diffs (38 lines):
diff -r c454d11155d0 -r 4ef5f97efe0e CHANGELOG
--- a/CHANGELOG Sun Jul 04 17:54:47 2021 +0200
+++ b/CHANGELOG Sun Jul 11 11:26:46 2021 +0200
@@ -1,3 +1,5 @@
+* Allow only fixed cost price as method for service
+
Version 6.0.0 - 2021-05-03
* Bug fixes (see mercurial logs for details)
* Deactivate variants when product is deactivated
diff -r c454d11155d0 -r 4ef5f97efe0e product.py
--- a/product.py Sun Jul 04 17:54:47 2021 +0200
+++ b/product.py Sun Jul 11 11:26:46 2021 +0200
@@ -14,7 +14,7 @@
from trytond.model import (
ModelView, ModelSQL, Model, UnionMixin, DeactivableMixin, sequence_ordered,
Exclude, fields)
-from trytond.pyson import Eval, If
+from trytond.pyson import Eval, If, Get
from trytond.transaction import Transaction
from trytond.pool import Pool
from trytond import backend
@@ -129,6 +129,16 @@
super().__setup__()
cls._order.insert(0, ('rec_name', 'ASC'))
+ types_cost_method = cls._cost_price_method_domain_per_type()
+ cls.cost_price_method.domain = [
+ Get(types_cost_method, Eval('type'), []),
+ ]
+ cls.cost_price_method.depends = ['type']
+
+ @classmethod
+ def _cost_price_method_domain_per_type(cls):
+ return {'service': [('cost_price_method', '=', 'fixed')]}
+
@classmethod
def multivalue_model(cls, field):
pool = Pool()