summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2017-01-13 15:18:17 +0100
committerNicolas Martinelli <nim@odoo.com>2017-01-16 08:35:35 +0100
commitdfd5cf95633d92da44cce014c6e175da90e1fafa (patch)
tree1ed876a8e73b80990daa335a40d628e35da1cbff
parentcd45a1acb4494faadab8df628543f1df0ddd9bd9 (diff)
[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
-rw-r--r--addons/stock_account/wizard/stock_change_standard_price.py4
-rw-r--r--addons/stock_account/wizard/stock_change_standard_price_views.xml6
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 @@
<field name="arch" type="xml">
<form string="Change Standard Price">
<separator string="Change Price"/>
+ <field name="counterpart_account_id_required" invisible="1"/>
<group>
<group>
<field name="new_price" string="Cost"/>
</group>
<group>
- <field name="counterpart_account_id"/>
+ <field name="counterpart_account_id"
+ attrs="{'invisible': [('counterpart_account_id_required', '=', False)], 'required': [('counterpart_account_id_required', '=', True)]}"/>
</group>
</group>
<footer>
@@ -34,4 +36,4 @@
</record>
</data>
-</odoo> \ No newline at end of file
+</odoo>