From 7bb4fe2e2166e1d7f56ba0486255a1df4df48201 Mon Sep 17 00:00:00 2001 From: rhe-odoo Date: Thu, 2 Feb 2023 09:23:31 +0000 Subject: [PATCH] [FIX] point_of_sale: default partner price list Before, when we tried to open the Partner detail screen, we had an issue when the price list weren't loaded. But since this commit: 40f0482b680a7872d338fa8fd10eec4663637b46 The price list are not mandatory anymore, we can get rid of the check that consisted of verifying the price list were set on the partners. closes odoo/odoo#111665 Signed-off-by: Trinh Jacky (trj) --- addons/point_of_sale/models/product.py | 2 +- .../PartnerListScreen/PartnerDetailsEdit.js | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/addons/point_of_sale/models/product.py b/addons/point_of_sale/models/product.py index 2ab5f867424..32db9580623 100644 --- a/addons/point_of_sale/models/product.py +++ b/addons/point_of_sale/models/product.py @@ -66,7 +66,7 @@ class ProductProduct(models.Model): pricelists = config.available_pricelist_ids else: pricelists = config.pricelist_id - price_per_pricelist_id = pricelists._price_get(self, quantity) + price_per_pricelist_id = pricelists._price_get(self, quantity) if pricelists else False pricelist_list = [{'name': pl.name, 'price': price_per_pricelist_id[pl.id]} for pl in pricelists] # Warehouses diff --git a/addons/point_of_sale/static/src/js/Screens/PartnerListScreen/PartnerDetailsEdit.js b/addons/point_of_sale/static/src/js/Screens/PartnerListScreen/PartnerDetailsEdit.js index 8b1bfcc0df7..bd8e78e5ddf 100644 --- a/addons/point_of_sale/static/src/js/Screens/PartnerListScreen/PartnerDetailsEdit.js +++ b/addons/point_of_sale/static/src/js/Screens/PartnerListScreen/PartnerDetailsEdit.js @@ -17,10 +17,8 @@ export class PartnerDetailsEdit extends PosComponent { this.changes = { country_id: partner.country_id && partner.country_id[0], state_id: partner.state_id && partner.state_id[0], + property_product_pricelist: this.setDefaultPricelist(partner) }; - if (!partner.property_product_pricelist) { - this.changes["property_product_pricelist"] = this.env.pos.default_pricelist.id; - } onMounted(() => { this.env.bus.on("save-partner", this, this.saveChanges); @@ -30,6 +28,16 @@ export class PartnerDetailsEdit extends PosComponent { this.env.bus.off("save-partner", this); }); } + setDefaultPricelist(partner) { + if (partner.property_product_pricelist) { + return partner.property_product_pricelist[0] + } + else if (this.env.pos.default_pricelist) { + return this.env.pos.default_pricelist.id; + } + return false; + } + get partnerImageUrl() { // We prioritize image_1920 in the `changes` field because we want // to show the uploaded image without fetching new data from the server.