Skip to content
Snippets Groups Projects
Commit cf62fdb4 authored by Nicolas Martinelli's avatar Nicolas Martinelli
Browse files

[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
parent a6cf37e9
No related branches found
No related tags found
No related merge requests found
...@@ -85,9 +85,17 @@ class product_pricelist(osv.osv): ...@@ -85,9 +85,17 @@ class product_pricelist(osv.osv):
comp = self.pool.get('res.company').browse(cr, uid, comp_id) comp = self.pool.get('res.company').browse(cr, uid, comp_id)
return comp.currency_id.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 = { _defaults = {
'active': lambda *a: 1, '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): def price_rule_get_multi(self, cr, uid, ids, products_by_qty_by_partner, context=None):
......
...@@ -139,6 +139,11 @@ ...@@ -139,6 +139,11 @@
<field name="date_start"/> <field name="date_start"/>
<field name="date_end"/> <field name="date_end"/>
<field name="price" string="Price"/> <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> </tree>
</field> </field>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment