[FIX] point_of_sale: load pricelists in pos
When we were loading pricelists for POS, we were putting the base_pricelist of an item in it. It comes from the prveious implementation on javascript side when it was the reference to the object that was shared. As we have put it in python in a dictionnary and we need to serilize the data. We also only take the fields we need in POS ISSUE-2968489 closes odoo/odoo#100425 X-original-commit: f15ac2b2688f68a049cdaa0580bb54f1e7784cab Signed-off-by: Masereel Pierre <pim@odoo.com>
This commit is contained in:
@@ -1795,6 +1795,30 @@ class PosSession(models.Model):
|
||||
domain = [('id', '=', self.config_id.pricelist_id.id)]
|
||||
return {'search_params': {'domain': domain, 'fields': ['name', 'display_name', 'discount_policy']}}
|
||||
|
||||
def _product_pricelist_item_fields(self):
|
||||
return [
|
||||
'id',
|
||||
'product_tmpl_id',
|
||||
'product_id',
|
||||
'pricelist_id',
|
||||
'price_surcharge',
|
||||
'price_discount',
|
||||
'price_round',
|
||||
'price_min_margin',
|
||||
'price_max_margin',
|
||||
'company_id',
|
||||
'currency_id',
|
||||
'date_start',
|
||||
'date_end',
|
||||
'compute_price',
|
||||
'fixed_price',
|
||||
'percent_price',
|
||||
'base_pricelist_id',
|
||||
'base',
|
||||
'categ_id',
|
||||
'min_quantity',
|
||||
]
|
||||
|
||||
def _get_pos_ui_product_pricelist(self, params):
|
||||
pricelists = self.env['product.pricelist'].search_read(**params['search_params'])
|
||||
for pricelist in pricelists:
|
||||
@@ -1802,9 +1826,8 @@ class PosSession(models.Model):
|
||||
|
||||
pricelist_by_id = {pricelist['id']: pricelist for pricelist in pricelists}
|
||||
pricelist_item_domain = [('pricelist_id', 'in', [p['id'] for p in pricelists])]
|
||||
for item in self.env['product.pricelist.item'].search_read(pricelist_item_domain, []):
|
||||
for item in self.env['product.pricelist.item'].search_read(pricelist_item_domain, self._product_pricelist_item_fields()):
|
||||
pricelist_by_id[item['pricelist_id'][0]]['items'].append(item)
|
||||
item['base_pricelist'] = pricelist_by_id.get(item['base_pricelist_id'][0]) if item['base_pricelist_id'] else None
|
||||
|
||||
return pricelists
|
||||
|
||||
|
||||
@@ -1409,7 +1409,11 @@ class Product extends PosModel {
|
||||
}
|
||||
|
||||
if (rule.base === 'pricelist') {
|
||||
price = self.get_price(rule.base_pricelist, quantity);
|
||||
let base_pricelist = _.find(self.pos.pricelists, function (pricelist) {
|
||||
return pricelist.id === rule.base_pricelist_id[0];});
|
||||
if (base_pricelist) {
|
||||
price = self.get_price(base_pricelist, quantity);
|
||||
}
|
||||
} else if (rule.base === 'standard_price') {
|
||||
price = self.standard_price;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user