summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGoffin Simon <sig@odoo.com>2016-04-21 15:19:32 +0200
committerGoffin Simon <sig@odoo.com>2016-06-27 15:47:58 +0200
commitd577eeaa6e63aeed09126efddcc856064e0b8ae3 (patch)
treeba8d84d54efb78b9e47b4fd1054fcacfdc5b8d06
parent3229629579cda57673fe99816deab0a6560b4f0e (diff)
[FIX] product: pricelist items
With the pricelist, it is possible to define a pricelist just for a variant. But in the product.product.form, only the pricelist items linked to the product template could be displayed. The field item_ids has been created in product.product model to display all the pricelist applied on a product. opw:674700
-rw-r--r--addons/product/product.py8
-rw-r--r--addons/product/product_view.xml16
2 files changed, 24 insertions, 0 deletions
diff --git a/addons/product/product.py b/addons/product/product.py
index e425058ea5a..3c2f1de74e6 100644
--- a/addons/product/product.py
+++ b/addons/product/product.py
@@ -942,6 +942,13 @@ class product_product(osv.osv):
break
return res
+ def _get_items(self, cr, uid, ids, field_name, args, context=None):
+ res = {}
+ for prod in self.browse(cr, uid, ids, context=context):
+ item_ids = self.pool['product.pricelist.item'].search(cr, uid, ['|', ('product_id', '=', prod.id), ('product_tmpl_id', '=', prod.product_tmpl_id.id)], context=context)
+ res[prod.id] = item_ids
+ return res
+
_columns = {
'price': fields.function(_product_price, fnct_inv=_set_product_lst_price, type='float', string='Price', digits_compute=dp.get_precision('Product Price')),
'price_extra': fields.function(_get_price_extra, type='float', string='Variant Extra Price', help="This is the sum of the extra price of all attributes", digits_compute=dp.get_precision('Product Price')),
@@ -978,6 +985,7 @@ class product_product(osv.osv):
groups="base.group_user", string="Cost"),
'volume': fields.float('Volume', help="The volume in m3."),
'weight': fields.float('Gross Weight', digits_compute=dp.get_precision('Stock Weight'), help="The weight of the contents in Kg, not including any packaging, etc."),
+ 'item_ids': fields.function(_get_items, type='many2many', relation='product.pricelist.item', string='Pricelist Items', store=False),
}
_defaults = {
diff --git a/addons/product/product_view.xml b/addons/product/product_view.xml
index fc0f557cf70..14f59d38b0c 100644
--- a/addons/product/product_view.xml
+++ b/addons/product/product_view.xml
@@ -470,6 +470,22 @@
<field name="name" position="after">
<field name="product_tmpl_id" class="oe_inline" readonly="1" invisible="1" attrs="{'required': [('id', '!=', False)]}"/>
</field>
+ <field name="item_ids" position="replace">
+ <field name="item_ids" widget="many2many">
+ <tree string="Pricelist Items">
+ <field name="name" string="Applicable On"/>
+ <field name="min_quantity"/>
+ <field name="date_start"/>
+ <field name="date_end"/>
+ <field name="price" string="Price"/>
+ <field name="base" invisible="1"/>
+ <field name="sequence" invisible="1"/>
+ <field name="price_discount" invisible="1"/>
+ <field name="applied_on" invisible="1"/>
+ <field name="compute_price" invisible="1"/>
+ </tree>
+ </field>
+ </field>
<xpath expr="//div[@class='oe_title']" position="inside">
<field name="attribute_value_ids" widget="many2many_tags" groups="product.group_product_variant"/>
</xpath>