From 8a201cb9b83cfa48ade24c8edde16a4117230721 Mon Sep 17 00:00:00 2001 From: Xavier Codinas Date: Fri, 22 Sep 2017 12:18:52 +0200 Subject: [PATCH] Limit cost method to fixed for service issue2356 review34701002 --- CHANGELOG | 1 + product.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f405511165..dadf34a117 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Limit cost method to fixed for service * Move cost_price from Template to Product Version 4.4.0 - 2017-05-01 diff --git a/product.py b/product.py index 610ea6d549..8346f62dd9 100644 --- a/product.py +++ b/product.py @@ -7,7 +7,7 @@ from decimal import Decimal from sql import Null, Column from trytond.model import ModelView, ModelSQL, Model, fields -from trytond.pyson import Eval +from trytond.pyson import Eval, If from trytond.transaction import Transaction from trytond.pool import Pool from trytond import backend @@ -60,7 +60,11 @@ class Template(ModelSQL, ModelView, CompanyMultiValueMixin): "Cost Price", digits=price_digits), 'get_cost_price') cost_price_method = fields.MultiValue(fields.Selection( COST_PRICE_METHODS, "Cost Price Method", required=True, - states=STATES, depends=DEPENDS)) + domain=[If((Eval('type') == 'service'), + ('cost_price_method', '=', 'fixed'), + (), + ) + ], states=STATES, depends=DEPENDS + ['type'])) cost_price_methods = fields.One2Many( 'product.cost_price_method', 'template', "Cost Price Methods") default_uom = fields.Many2One('product.uom', 'Default UOM', required=True,