From dfd5cf95633d92da44cce014c6e175da90e1fafa Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 13 Jan 2017 15:18:17 +0100 Subject: [PATCH] [IMP] stock_account: Counter-Part Account In commit 40bd4a2f051, the counter-part account is made selectable and required when changing the price of a product. However, the same wizard is reused for the "Compute from BOM" feature, in module `product_extended`. This forces the user to set an account even if the product valuation is not "Perpetual (automated)". In this commit, the field becomes required only if the product valuation is "Perpetual (automated)". opw-697866 --- addons/stock_account/wizard/stock_change_standard_price.py | 4 +++- .../wizard/stock_change_standard_price_views.xml | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/stock_account/wizard/stock_change_standard_price.py b/addons/stock_account/wizard/stock_change_standard_price.py index 812d4dc9240..16135e21214 100644 --- a/addons/stock_account/wizard/stock_change_standard_price.py +++ b/addons/stock_account/wizard/stock_change_standard_price.py @@ -16,7 +16,8 @@ class StockChangeStandardPrice(models.TransientModel): "If cost price is decreased, stock variation account will be creadited and stock input account will be debited.") counterpart_account_id = fields.Many2one( 'account.account', string="Counter-Part Account", - domain=[('deprecated', '=', False)], required=True) + domain=[('deprecated', '=', False)]) + counterpart_account_id_required = fields.Boolean(string="Counter-Part Account Required") @api.model def default_get(self, fields): @@ -27,6 +28,7 @@ class StockChangeStandardPrice(models.TransientModel): res['new_price'] = product_or_template.standard_price if 'counterpart_account_id' in fields and 'counterpart_account_id' not in res: res['counterpart_account_id'] = product_or_template.property_account_expense_id.id or product_or_template.categ_id.property_account_expense_categ_id.id + res['counterpart_account_id_required'] = bool(product_or_template.valuation == 'real_time') return res @api.multi diff --git a/addons/stock_account/wizard/stock_change_standard_price_views.xml b/addons/stock_account/wizard/stock_change_standard_price_views.xml index 806f6883b72..01f4d61318a 100644 --- a/addons/stock_account/wizard/stock_change_standard_price_views.xml +++ b/addons/stock_account/wizard/stock_change_standard_price_views.xml @@ -7,12 +7,14 @@
+ - +