[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
This commit is contained in:
Victor Feyens
2022-05-12 17:34:51 +02:00
parent a945d9043c
commit a84c7ace37
4 changed files with 32 additions and 16 deletions
@@ -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):
@@ -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')
@@ -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:
@@ -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):