Permalink
Browse files

[IMP] product: pricelists - multiple prices per product

currently, if the user selects Multiple prices per product
in Multiple Product Prices, the user cannot set product
directly from product.pricelist formview.

purpose of this commit is to make multiple prices par product
fromview quick editable and reflect that to the product.product formview.

Task: #1904777
Close: #30540
  • Loading branch information...
mgh-odoo committed Jan 25, 2019
1 parent 7688440 commit 1926394cb5db16bbd426d42a13bf16af2c4bf914
Showing with 36 additions and 6 deletions.
  1. +10 −4 addons/product/models/product_pricelist.py
  2. +26 −2 addons/product/views/product_pricelist_views.xml
@@ -18,10 +18,11 @@ def _get_default_currency_id(self):
return self.env.user.company_id.currency_id.id

def _get_default_item_ids(self):
ProductPricelistItem = self.env['product.pricelist.item']
vals = ProductPricelistItem.default_get(list(ProductPricelistItem._fields))
vals.update(compute_price='formula')
return [[0, False, vals]]
if self.user_has_groups('product.group_pricelist_item'):
ProductPricelistItem = self.env['product.pricelist.item']
vals = ProductPricelistItem.default_get(list(ProductPricelistItem._fields))
vals.update(compute_price='formula')
return [[0, False, vals]]

name = fields.Char('Pricelist Name', required=True, translate=True)
active = fields.Boolean('Active', default=True, help="If unchecked, it will allow you to hide the pricelist without removing it.")
@@ -494,3 +495,8 @@ def _onchange_compute_price(self):
'price_min_margin': 0.0,
'price_max_margin': 0.0,
})

@api.onchange('product_tmpl_id')
def _onchange_product_tmpl_id(self):
if self.user_has_groups('product.group_product_pricelist') and self.user_has_groups('product.group_product_variant'):
return {'value': {'product_id': False}}
@@ -149,9 +149,9 @@
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
<field name="country_group_ids"/>
</group>
<div groups="product.group_pricelist_item">
<div>
<separator string="Pricelist Items"/>
<field name="item_ids" nolabel="1" context="{'default_base':'list_price'}">
<field name="item_ids" nolabel="1" context="{'default_base':'list_price'}" groups="product.group_pricelist_item">
<tree string="Pricelist Items">
<field name="name" string="Applicable On"/>
<field name="min_quantity"/>
@@ -169,6 +169,30 @@
</form>
</field>
</record>

<record id="product_pricelist_view_inherit" model="ir.ui.view">
<field name="name">product.pricelist.form.inherit</field>
<field name="model">product.pricelist</field>
<field name="inherit_id" ref="product.product_pricelist_view"/>
<field name="groups_id" eval="[(4, ref('product.group_product_pricelist'))]"/>
<field name="arch" type="xml">
<field name="item_ids" position="replace">
<field name="item_ids" nolabel="1" context="{'default_base':'list_price', 'default_applied_on' :'1_product'}">
<tree string="Pricelist Items" editable="bottom">
<field name="product_tmpl_id" string="Products" required="1"/>
<field name="product_id" string="Variants" groups="product.group_product_variant" domain="[('product_tmpl_id', '=', product_tmpl_id)]"/>
<field name="fixed_price" string="Price" widget="monetary"/>
<field name="min_quantity"/>
<field name="date_start"/>
<field name="date_end"/>
<field name="base" invisible="1"/>
<field name="applied_on" invisible="1"/>
</tree>
</field>
</field>
</field>
</record>

<record model="ir.ui.view" id="inherits_website_sale_country_group_form">
<field name="name">website_sale.country_group.form</field>
<field name="model">res.country.group</field>

0 comments on commit 1926394

Please sign in to comment.