[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
This commit is contained in:
@@ -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 = {
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user