[FIX] product: default pricelist item

By default, a pricelist can be created without pricelist item. However,
if a user does not have the rights to manage the pricelist items (or
simply does not want to manage them), the feature is unusable. Indeed,
the user will create a new pricelist (for example, in a new currency),
but this pricelist will not have any item. Therefore, the pricelist will
not apply to anything.

The fix creates a pricelist item by default. The pricelist item is the
most generic possible: it applies to all products and uses the list
price as a base price.

opw-667607
This commit is contained in:
Nicolas Martinelli
2016-02-15 14:57:45 +01:00
parent a6cf37e930
commit cf62fdb44b
2 changed files with 14 additions and 1 deletions
+9 -1
View File
@@ -85,9 +85,17 @@ class product_pricelist(osv.osv):
comp = self.pool.get('res.company').browse(cr, uid, comp_id)
return comp.currency_id.id
def _get_item_ids(self, cr, uid, ctx):
ProductPricelistItem = self.pool.get('product.pricelist.item')
fields_list = ProductPricelistItem._defaults.keys()
vals = ProductPricelistItem.default_get(cr, uid, fields_list, context=ctx)
vals['compute_price'] = 'formula'
return [[0, False, vals]]
_defaults = {
'active': lambda *a: 1,
"currency_id": _get_currency
"currency_id": _get_currency,
'item_ids': _get_item_ids,
}
def price_rule_get_multi(self, cr, uid, ids, products_by_qty_by_partner, context=None):
+5
View File
@@ -139,6 +139,11 @@
<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>
</div>