From ab7ec7829d590be46e134d59a26aa9134da87339 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 28 Dec 2024 23:52:48 +0100 Subject: [PATCH] [MIG] product_usability_akretion to v18 --- product_usability_akretion/__manifest__.py | 11 +++++----- product_usability_akretion/models/__init__.py | 1 - .../models/product_category.py | 5 ++--- .../models/product_pricelist.py | 11 ---------- .../models/product_product.py | 2 +- .../models/product_template.py | 20 ++++++++++++++++--- .../views/product_category_view.xml | 19 ------------------ .../views/product_config_menu.xml | 4 ++-- ...icelist_view.xml => product_pricelist.xml} | 2 +- .../views/product_product.xml | 12 ++++++++--- ...info_view.xml => product_supplierinfo.xml} | 12 +---------- ...template_view.xml => product_template.xml} | 7 ++----- 12 files changed, 40 insertions(+), 66 deletions(-) delete mode 100644 product_usability_akretion/models/product_pricelist.py delete mode 100644 product_usability_akretion/views/product_category_view.xml rename product_usability_akretion/views/{product_pricelist_view.xml => product_pricelist.xml} (96%) rename product_usability_akretion/views/{product_supplierinfo_view.xml => product_supplierinfo.xml} (57%) rename product_usability_akretion/views/{product_template_view.xml => product_template.xml} (81%) diff --git a/product_usability_akretion/__manifest__.py b/product_usability_akretion/__manifest__.py index b2a30d8..19f21d7 100644 --- a/product_usability_akretion/__manifest__.py +++ b/product_usability_akretion/__manifest__.py @@ -5,7 +5,7 @@ { 'name': 'Product Usability', - 'version': '16.0.1.0.0', + 'version': '18.0.1.0.0', 'category': 'Product', 'license': 'AGPL-3', 'summary': 'Small usability enhancements to the product module', @@ -28,13 +28,12 @@ This module has been written by Alexis de Lattre from Akretion # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). @@ -6,8 +6,7 @@ from odoo import fields, models class ProductCategory(models.Model): - _inherit = ['product.category', "mail.thread", "mail.activity.mixin"] - _name = 'product.category' + _inherit = 'product.category' name = fields.Char(tracking=10) parent_id = fields.Many2one(tracking=20) diff --git a/product_usability_akretion/models/product_pricelist.py b/product_usability_akretion/models/product_pricelist.py deleted file mode 100644 index b5c8a39..0000000 --- a/product_usability_akretion/models/product_pricelist.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright 2017-2022 Akretion (http://www.akretion.com/) -# @author: Alexis de Lattre -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import fields, models - - -class ProductPricelist(models.Model): - _inherit = 'product.pricelist' - - company_id = fields.Many2one(default=lambda self: self.env.company) diff --git a/product_usability_akretion/models/product_product.py b/product_usability_akretion/models/product_product.py index 989c1c2..e3207d2 100644 --- a/product_usability_akretion/models/product_product.py +++ b/product_usability_akretion/models/product_product.py @@ -1,4 +1,4 @@ -# Copyright 2015-2022 Akretion (http://www.akretion.com) +# Copyright 2015-2024 Akretion (https://www.akretion.com) # @author Alexis de Lattre # @author Raphaël Valyi # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/product_usability_akretion/models/product_template.py b/product_usability_akretion/models/product_template.py index e68ad56..717611b 100644 --- a/product_usability_akretion/models/product_template.py +++ b/product_usability_akretion/models/product_template.py @@ -1,4 +1,4 @@ -# Copyright 2015-2022 Akretion (http://www.akretion.com) +# Copyright 2015-2024 Akretion (https://www.akretion.com) # @author Alexis de Lattre # @author Raphaël Valyi # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -14,7 +14,9 @@ class ProductTemplate(models.Model): # in v10, that field was defined in procurement_suggest, but we will # probably not port procurement_suggest because it is native in v14 seller_id = fields.Many2one( - 'res.partner', related='seller_ids.partner_id', store=True, + 'res.partner', + compute="_compute_seller_id", + search="_search_seller_id", string='Main Supplier') # in v14, I noticed that the tracking of the fields of product.template @@ -26,7 +28,7 @@ class ProductTemplate(models.Model): barcode = fields.Char(tracking=20) default_code = fields.Char(tracking=30) categ_id = fields.Many2one(tracking=40) - detailed_type = fields.Selection(tracking=50) + type = fields.Selection(tracking=50) list_price = fields.Float(tracking=60, default=0) # native: default=1.0 weight = fields.Float(tracking=70) sale_ok = fields.Boolean(tracking=80) @@ -35,6 +37,18 @@ class ProductTemplate(models.Model): company_id = fields.Many2one(tracking=110) barcode_type = fields.Char(compute='_compute_template_barcode_type') + def _search_seller_id(self, operator, value): + # searching on the first line of a o2m is not that easy + # So we search all potential matching products + # Then we filter on the seller_id + records = self.search([("seller_ids.partner_id", operator, value)]) + records = records.filtered_domain([("seller_id", operator, value)]) + return [("id", "in", records.ids)] + + def _compute_seller_id(self): + for record in self: + record.seller_id = fields.first(record.seller_ids).partner_id + # precompute=True doesn't work on product.template # (works fine on product.product), probably because we don't depend # on 'barcode' diff --git a/product_usability_akretion/views/product_category_view.xml b/product_usability_akretion/views/product_category_view.xml deleted file mode 100644 index f8a8b4f..0000000 --- a/product_usability_akretion/views/product_category_view.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - product.category - - - -
- - - -
-
-
-
- -
- diff --git a/product_usability_akretion/views/product_config_menu.xml b/product_usability_akretion/views/product_config_menu.xml index bf165b6..73272ce 100644 --- a/product_usability_akretion/views/product_config_menu.xml +++ b/product_usability_akretion/views/product_config_menu.xml @@ -1,6 +1,6 @@ @@ -10,7 +10,7 @@ Price Rules product.pricelist.item - tree,form + list,form [('pricelist_id', '=', active_id)] {'product_pricelist_item_main_view': True} diff --git a/product_usability_akretion/views/product_product.xml b/product_usability_akretion/views/product_product.xml index ce9bcd3..9e75159 100644 --- a/product_usability_akretion/views/product_product.xml +++ b/product_usability_akretion/views/product_product.xml @@ -1,6 +1,6 @@ @@ -13,10 +13,16 @@ - + + monetary + {'currency_field': 'currency_id'} + + + monetary + {'currency_field': 'cost_currency_id'} @@ -27,7 +33,7 @@ - + diff --git a/product_usability_akretion/views/product_supplierinfo_view.xml b/product_usability_akretion/views/product_supplierinfo.xml similarity index 57% rename from product_usability_akretion/views/product_supplierinfo_view.xml rename to product_usability_akretion/views/product_supplierinfo.xml index b8eea5d..0bee5ed 100644 --- a/product_usability_akretion/views/product_supplierinfo_view.xml +++ b/product_usability_akretion/views/product_supplierinfo.xml @@ -1,22 +1,12 @@ - - product.supplierinfo - - - - - - - - product.supplierinfo diff --git a/product_usability_akretion/views/product_template_view.xml b/product_usability_akretion/views/product_template.xml similarity index 81% rename from product_usability_akretion/views/product_template_view.xml rename to product_usability_akretion/views/product_template.xml index 140722d..f6989f8 100644 --- a/product_usability_akretion/views/product_template_view.xml +++ b/product_usability_akretion/views/product_template.xml @@ -14,11 +14,8 @@ - + - - {'group_by': 'detailed_type'} - @@ -30,7 +27,7 @@ - +