From a84c7ace373f62a4c681e666f0c32d2de3fbf365 Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Tue, 10 May 2022 15:38:48 +0000 Subject: [PATCH] [IMP] sale_product_*: clean python classes specifications * Enforce line length for fields spec * clean one little useless import * prefer single quotes for strings not shown to the end user Part-of: odoo/odoo#91222 --- .../models/product_template.py | 13 +++++++++---- .../models/sale_order_line.py | 9 ++++++--- .../models/product_template.py | 19 ++++++++++++------- .../sale_product_matrix/models/sale_order.py | 7 +++++-- 4 files changed, 32 insertions(+), 16 deletions(-) diff --git a/addons/sale_product_configurator/models/product_template.py b/addons/sale_product_configurator/models/product_template.py index 51b52c6bc0c..9bb19f04e9d 100644 --- a/addons/sale_product_configurator/models/product_template.py +++ b/addons/sale_product_configurator/models/product_template.py @@ -9,10 +9,15 @@ class ProductTemplate(models.Model): _check_company_auto = True optional_product_ids = fields.Many2many( - 'product.template', 'product_optional_rel', 'src_id', 'dest_id', - string='Optional Products', help="Optional Products are suggested " - "whenever the customer hits *Add to Cart* (cross-sell strategy, " - "e.g. for computers: warranty, software, etc.).", check_company=True) + comodel_name='product.template', + relation='product_optional_rel', + column1='src_id', + column2='dest_id', + string="Optional Products", + help="Optional Products are suggested " + "whenever the customer hits *Add to Cart* (cross-sell strategy, " + "e.g. for computers: warranty, software, etc.).", + check_company=True) @api.depends('attribute_line_ids.value_ids.is_custom', 'attribute_line_ids.attribute_id.create_variant') def _compute_has_configurable_attributes(self): diff --git a/addons/sale_product_configurator/models/sale_order_line.py b/addons/sale_product_configurator/models/sale_order_line.py index 62d613a9bdf..913be563dd2 100644 --- a/addons/sale_product_configurator/models/sale_order_line.py +++ b/addons/sale_product_configurator/models/sale_order_line.py @@ -5,7 +5,10 @@ from odoo import fields, models class SaleOrderLine(models.Model): - _inherit = "sale.order.line" + _inherit = 'sale.order.line' - is_configurable_product = fields.Boolean('Is the product configurable?', related="product_template_id.has_configurable_attributes") - product_template_attribute_value_ids = fields.Many2many(related='product_id.product_template_attribute_value_ids', readonly=True) + is_configurable_product = fields.Boolean( + string="Is the product configurable?", + related='product_template_id.has_configurable_attributes') + product_template_attribute_value_ids = fields.Many2many( + related='product_id.product_template_attribute_value_ids') diff --git a/addons/sale_product_matrix/models/product_template.py b/addons/sale_product_matrix/models/product_template.py index 8440b5b3620..6493493229c 100644 --- a/addons/sale_product_matrix/models/product_template.py +++ b/addons/sale_product_matrix/models/product_template.py @@ -1,19 +1,24 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, models, fields + +from odoo import models, fields class ProductTemplate(models.Model): _inherit = 'product.template' - product_add_mode = fields.Selection([ - ('configurator', 'Product Configurator'), - ('matrix', 'Order Grid Entry'), - ], string='Add product mode', default='configurator', help="Configurator: choose attribute values to add the matching \ - product variant to the order.\nGrid: add several variants at once from the grid of attribute values") + product_add_mode = fields.Selection( + selection=[ + ('configurator', "Product Configurator"), + ('matrix', "Order Grid Entry"), + ], + string="Add product mode", + default='configurator', + help="Configurator: choose attribute values to add the matching product variant to the order." + "\nGrid: add several variants at once from the grid of attribute values") def get_single_product_variant(self): - res = super(ProductTemplate, self).get_single_product_variant() + res = super().get_single_product_variant() if self.has_configurable_attributes: res['mode'] = self.product_add_mode else: diff --git a/addons/sale_product_matrix/models/sale_order.py b/addons/sale_product_matrix/models/sale_order.py index a01c40fda2d..038f9d9cf0f 100644 --- a/addons/sale_product_matrix/models/sale_order.py +++ b/addons/sale_product_matrix/models/sale_order.py @@ -10,7 +10,8 @@ class SaleOrder(models.Model): report_grids = fields.Boolean( string="Print Variant Grids", default=True, - help="If set, the matrix of the products configurable by matrix will be shown on the report of the order.") + help="If set, the matrix of the products configurable by matrix will" + " be shown on the report of the order.") """ Matrix loading and update: fields and methods : @@ -30,7 +31,9 @@ class SaleOrder(models.Model): help="Whether the grid field contains a new matrix to apply or not.") grid = fields.Char( "Matrix local storage", store=False, - help="Technical local storage of grid. \nIf grid_update, will be loaded on the SO. \nIf not, represents the matrix to open.") + help="Technical local storage of grid. " + "\nIf grid_update, will be loaded on the SO." + "\nIf not, represents the matrix to open.") @api.onchange('grid_product_tmpl_id') def _set_grid_up(self):