Skip to content
Permalink
Browse files

[IMP] product: corrected pricelist on product variant

current Behaviour:
==================

Currently there is no way to set fix price on product variant when Multiple prices per product.
if we add on variant it's directly applied on template(all variant)

Case For Product Template :
   - If user put a fix price on the product (template) and then try to check the product, he will find a line with that fix price on the "Sales" tab "Pricing" section, now if the current user tries to change this price he/she can easily change it, untimately the current user has the information that the product has some pricelist on it and its clearly visible here.

Case For Product Variants :
   - If User put a fix prices on the product variants and then try to check any product variant, he will not find any line with that fix price on the "Sales" tab "Pricing" section, so now if the product manager wants to change the price which is set by the pricelist (fixed price), he/she does not have a clue what is the price..

Fixed in brach:
    -In Product Pricelist(Prices computed from formulas):
        -Remove the product variant option. Keep only 3 radio (Global, Category and Porduct)
        -when 'product' is selected:
            Product field is mandatory
            Product Variant isn't mandatory(invisible if variant is disabled)
	-Put filters to show only products that can be sold.
	-put filter to show product variants of selected product only.

    - In Multiple prices per product:
        - Able to add pricelist only for single variant.

    - As the option "product variant" has been removed from model itself, It had to be removed from test cases too.

Related Task ID : 1870321
  • Loading branch information...
hdh-odoo committed Jan 29, 2019
1 parent 9ea4fef commit e0c5f3726f1b0f2f530a7223788764e33effe90f
@@ -49,13 +49,15 @@ def test_01_pos_basic_order(self):
}), (0, 0, {
'compute_price': 'fixed',
'fixed_price': 2,
'applied_on': '0_product_variant',
'applied_on': '1_product',
'product_id': env.ref('point_of_sale.wall_shelf').id,
'product_tmpl_id': env.ref('point_of_sale.wall_shelf_product_template').id,
}), (0, 0, {
'compute_price': 'fixed',
'fixed_price': 13.95, # test for issues like in 7f260ab517ebde634fc274e928eb062463f0d88f
'applied_on': '0_product_variant',
'applied_on': '1_product',
'product_id': env.ref('point_of_sale.small_shelf').id,
'product_tmpl_id': env.ref('point_of_sale.small_shelf_product_template').id,
})],
})

@@ -64,18 +66,21 @@ def test_01_pos_basic_order(self):
'item_ids': [(0, 0, {
'compute_price': 'percentage',
'percent_price': 100,
'applied_on': '0_product_variant',
'applied_on': '1_product',
'product_id': env.ref('point_of_sale.wall_shelf').id,
'product_tmpl_id': env.ref('point_of_sale.wall_shelf_product_template').id,
}), (0, 0, {
'compute_price': 'percentage',
'percent_price': 99,
'applied_on': '0_product_variant',
'applied_on': '1_product',
'product_id': env.ref('point_of_sale.small_shelf').id,
'product_tmpl_id': env.ref('point_of_sale.small_shelf_product_template').id,
}), (0, 0, {
'compute_price': 'percentage',
'percent_price': 0,
'applied_on': '0_product_variant',
'applied_on': '1_product',
'product_id': env.ref('point_of_sale.magnetic_board').id,
'product_tmpl_id': env.ref('point_of_sale.magnetic_board_product_template').id,
})],
})

@@ -85,34 +90,39 @@ def test_01_pos_basic_order(self):
'compute_price': 'formula',
'price_discount': 6,
'price_surcharge': 5,
'applied_on': '0_product_variant',
'applied_on': '1_product',
'product_id': env.ref('point_of_sale.wall_shelf').id,
'product_tmpl_id': env.ref('point_of_sale.wall_shelf_product_template').id,
}), (0, 0, {
# .99 prices
'compute_price': 'formula',
'price_surcharge': -0.01,
'price_round': 1,
'applied_on': '0_product_variant',
'applied_on': '1_product',
'product_id': env.ref('point_of_sale.small_shelf').id,
'product_tmpl_id': env.ref('point_of_sale.small_shelf_product_template').id,
}), (0, 0, {
'compute_price': 'formula',
'price_min_margin': 10,
'price_max_margin': 100,
'applied_on': '0_product_variant',
'applied_on': '1_product',
'product_id': env.ref('point_of_sale.magnetic_board').id,
'product_tmpl_id': env.ref('point_of_sale.magnetic_board_product_template').id,
}), (0, 0, {
'compute_price': 'formula',
'price_surcharge': 10,
'price_max_margin': 5,
'applied_on': '0_product_variant',
'applied_on': '1_product',
'product_id': env.ref('point_of_sale.monitor_stand').id,
'product_tmpl_id': env.ref('point_of_sale.monitor_stand_product_template').id,
}), (0, 0, {
'compute_price': 'formula',
'price_discount': -100,
'price_min_margin': 5,
'price_max_margin': 20,
'applied_on': '0_product_variant',
'applied_on': '1_product',
'product_id': env.ref('point_of_sale.desk_pad').id,
'product_tmpl_id': env.ref('point_of_sale.desk_pad_product_template').id,
})],
})

@@ -121,21 +131,24 @@ def test_01_pos_basic_order(self):
'item_ids': [(0, 0, {
'compute_price': 'fixed',
'fixed_price': 1,
'applied_on': '0_product_variant',
'applied_on': '1_product',
'min_quantity': 2,
'product_id': env.ref('point_of_sale.wall_shelf').id,
'product_tmpl_id': env.ref('point_of_sale.wall_shelf_product_template').id,
}), (0, 0, {
'compute_price': 'fixed',
'fixed_price': 2,
'applied_on': '0_product_variant',
'applied_on': '1_product',
'min_quantity': 1,
'product_id': env.ref('point_of_sale.wall_shelf').id,
'product_tmpl_id': env.ref('point_of_sale.wall_shelf_product_template').id,
}), (0, 0, {
'compute_price': 'fixed',
'fixed_price': 2,
'applied_on': '0_product_variant',
'applied_on': '1_product',
'min_quantity': 2,
'product_id': env.ref('point_of_sale.product_product_consumable').id,
'product_tmpl_id': env.ref('point_of_sale.product_product_consumable_product_template').id,
})],
})

@@ -130,8 +130,8 @@ class ProductProduct(models.Model):
volume = fields.Float('Volume')
weight = fields.Float('Weight', digits=dp.get_precision('Stock Weight'))

pricelist_item_ids = fields.Many2many(
'product.pricelist.item', 'Pricelist Items', compute='_get_pricelist_items')
pricelist_item_ids = fields.One2many(
'product.pricelist.item', 'product_id', 'Variant Pricelist Items')

packaging_ids = fields.One2many(
'product.packaging', 'product_id', 'Product Packages',
@@ -271,13 +271,6 @@ def _force_write_image_on_fallback(self):
('active', '=', True),
]) <= 1

@api.one
def _get_pricelist_items(self):
self.pricelist_item_ids = self.env['product.pricelist.item'].search([
'|',
('product_id', '=', self.id),
('product_tmpl_id', '=', self.product_tmpl_id.id)]).ids

@api.constrains('attribute_value_ids')
def _check_attribute_value_ids(self):
for product in self:
@@ -411,8 +411,7 @@ class PricelistItem(models.Model):
applied_on = fields.Selection([
('3_global', 'Global'),
('2_product_category', ' Product Category'),
('1_product', 'Product'),
('0_product_variant', 'Product Variant')], "Apply On",
('1_product', 'Product')], "Apply On",
default='3_global', required=True,
help='Pricelist Item applicable on selected option')
base = fields.Selection([
@@ -497,10 +496,9 @@ def _get_pricelist_item_name_price(self):

@api.onchange('applied_on')
def _onchange_applied_on(self):
if self.applied_on != '0_product_variant':
self.product_id = False
if self.applied_on != '1_product':
self.product_tmpl_id = False
self.product_id = False
if self.applied_on != '2_product_category':
self.categ_id = False

@@ -519,6 +517,11 @@ def _onchange_compute_price(self):
'price_max_margin': 0.0,
})

@api.onchange('product_tmpl_id')
def _onchange_product_tmpl_id(self):
if self.product_tmpl_id:
self.product_id = False

@api.multi
def write(self, values):
res = super(PricelistItem, self).write(values)
@@ -24,13 +24,15 @@ def setUp(self):
'base': 'list_price', # based on public price
'price_discount': 10,
'product_id': self.usb_adapter.id,
'applied_on': '0_product_variant',
'applied_on': '1_product',
'product_tmpl_id': self.usb_adapter.product_tmpl_id.id,
}), (0, 0, {
'compute_price': 'formula',
'base': 'list_price', # based on public price
'price_surcharge': -0.5,
'product_id': self.datacard.id,
'applied_on': '0_product_variant',
'product_tmpl_id': self.datacard.product_tmpl_id.id,
'applied_on': '1_product',
})]
})

@@ -83,12 +85,13 @@ def test_20_pricelist_uom(self):

self.env['product.pricelist.item'].create({
'pricelist_id': self.public_pricelist.id,
'applied_on': '0_product_variant',
'applied_on': '1_product',
'compute_price': 'formula',
'base': 'list_price', # based on public price
'min_quantity': 3, # min = 3 tonnes
'price_surcharge': -10, # -10 EUR / tonne
'product_id': spam_id.id
'product_id': spam_id.id,
'product_tmpl_id': spam_id.product_tmpl_id.id
})
pricelist = self.public_pricelist

@@ -34,13 +34,15 @@ def setUp(self):
'name': '10% Discount on Assemble Computer',
'applied_on': '1_product',
'product_id': self.ipad_retina_display.id,
'product_tmpl_id': self.ipad_retina_display.product_tmpl_id.id,
'compute_price': 'formula',
'base': 'list_price',
'price_discount': 10
}), (0, 0, {
'name': '1 surchange on Laptop',
'applied_on': '1_product',
'product_id': self.laptop_E5023.id,
'product_tmpl_id': self.laptop_E5023.product_tmpl_id.id,
'compute_price': 'formula',
'base': 'list_price',
'price_surcharge': 1
@@ -54,7 +56,7 @@ def setUp(self):
'price_discount': 5
}), (0, 0, {
'name': '30% Discount on all products',
'applied_on': '0_product_variant',
'applied_on': '1_product',
'date_start': '2011-12-27',
'date_end': '2011-12-31',
'compute_price': 'formula',
@@ -28,8 +28,8 @@
<group>
<field name="applied_on" widget="radio"/>
<field name="categ_id" attrs="{'invisible':[('applied_on', '!=', '2_product_category')], 'required':[('applied_on', '=', '2_product_category')]}"/>
<field name="product_tmpl_id" attrs="{'invisible':[('applied_on', '!=', '1_product')],'required':[('applied_on', '=', '1_product')]}" string="Product"/>
<field name="product_id" attrs="{'invisible':[('applied_on', '!=', '0_product_variant')],'required':[('applied_on', '=', '0_product_variant')]}" string="Product Variant"/>
<field name="product_tmpl_id" attrs="{'invisible':[('applied_on', '!=', '1_product')],'required':[('applied_on', '=', '1_product')]}" string="Product" domain="[('sale_ok','=',True)]"/>
<field name="product_id" domain="[('product_tmpl_id', '=', product_tmpl_id)]" attrs="{'invisible':[('applied_on', '!=', '1_product')]}" string="Product Variant" groups="product.group_product_variant"/>
</group>
<group>
<field name="min_quantity"/>
@@ -154,6 +154,7 @@
<field name="item_ids" nolabel="1" context="{'default_base':'list_price'}">
<tree string="Pricelist Items">
<field name="name" string="Applicable On"/>
<field name="product_id" groups="product.group_product_variant"/>
<field name="min_quantity"/>
<field name="date_start"/>
<field name="date_end"/>
@@ -78,6 +78,8 @@
<field name="item_ids" nolabel="1" mode="tree,kanban" context="{'default_base':'list_price', 'default_applied_on' :'1_product'}">
<tree string="Pricelist Items" editable="bottom">
<field name="pricelist_id" string="Pricelist" required='1'/>
<field name="product_tmpl_id" invisible="1"/>
<field name="product_id" groups="product.group_product_variant" domain="[('product_tmpl_id', '=', product_tmpl_id)]" />
<field name="currency_id" invisible="1"/>
<field name="fixed_price" string="Price" required='1' widget='monetary' options="{'currency_field': 'currency_id'}"/>
<field name="min_quantity"/>
@@ -398,17 +400,17 @@
<field name="name" position="after">
<field name="product_tmpl_id" class="oe_read_only oe_inline" readonly="1" attrs="{'required': [('id', '!=', False)]}"/>
</field>
<field name="item_ids" position="inside">
<field name="pricelist_item_ids" widget="many2many">
<tree string="Pricelist Items">
<field name="item_ids" position="replace">
<field name="pricelist_item_ids" context="{'default_base':'list_price', 'default_applied_on' :'1_product', 'default_product_tmpl_id': product_tmpl_id}" mode="tree,kanban">
<tree string="Pricelist Items" editable="bottom">
<field name="pricelist_id"/>
<field name="name" string="Applicable On"/>
<field name="product_id" invisible="1"/>
<field name="product_tmpl_id" invisible="1"/>
<field name="fixed_price" string="Price"/>
<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"/>

0 comments on commit e0c5f37

Please sign in to comment.
You can’t perform that action at this time.