Initialize v18 branch

Rename *_usability modules to *_usability_akretion
This commit is contained in:
Alexis de Lattre
2024-12-24 10:11:21 +01:00
parent 9913924202
commit 13744fc404
264 changed files with 50 additions and 87 deletions

View File

@@ -0,0 +1,5 @@
from . import product_product
from . import product_template
from . import product_supplierinfo
from . import product_pricelist
from . import product_category

View File

@@ -0,0 +1,13 @@
# Copyright 2022 Akretion (https://www.akretion.com).
# @author Sébastien BEAU <sebastien.beau@akretion.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ProductCategory(models.Model):
_inherit = ['product.category', "mail.thread", "mail.activity.mixin"]
_name = 'product.category'
name = fields.Char(tracking=10)
parent_id = fields.Many2one(tracking=20)

View File

@@ -0,0 +1,11 @@
# Copyright 2017-2022 Akretion (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# 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)

View File

@@ -0,0 +1,46 @@
# Copyright 2015-2022 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Raphaël Valyi <rvalyi@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models, fields
from stdnum.ean import is_valid
class ProductProduct(models.Model):
_inherit = 'product.product'
default_code = fields.Char(copy=False, tracking=10)
barcode = fields.Char(tracking=20)
weight = fields.Float(tracking=30)
active = fields.Boolean(tracking=40)
barcode_type = fields.Char(compute='_compute_barcode_type')
_sql_constraints = [(
# Maybe it could be better to have a constrain per company
# but the company_id field is on product.template,
# not on product.product
# If it's a problem, we'll create a company_id field on
# product.product
'default_code_uniq',
'unique(default_code)',
'This internal reference already exists!')]
@api.model
def _get_barcode_type(self, barcode):
barcode_type = False
size2label = {
8: 'EAN-8',
13: 'EAN-13',
14: 'GTIN-14',
}
if barcode:
size = len(barcode)
if size in size2label and is_valid(barcode):
barcode_type = size2label[size]
return barcode_type
@api.depends('barcode')
def _compute_barcode_type(self):
for product in self:
product.barcode_type = self._get_barcode_type(product.barcode)

View File

@@ -0,0 +1,12 @@
# Copyright 2015-2022 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Raphaël Valyi <rvalyi@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ProductSupplierinfo(models.Model):
_inherit = 'product.supplierinfo'
partner_id = fields.Many2one(domain=[('parent_id', '=', False)], ondelete='restrict')

View File

@@ -0,0 +1,49 @@
# Copyright 2015-2022 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Raphaël Valyi <rvalyi@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models, fields
class ProductTemplate(models.Model):
_inherit = 'product.template'
# restore v8 native field
# https://github.com/odoo/odoo/blob/8.0/addons/product/product.py#L592
# 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,
string='Main Supplier')
# in v14, I noticed that the tracking of the fields of product.template
# are only shown in the form view of product.template, not in the form
# view of product.product
name = fields.Char(tracking=10)
uom_id = fields.Many2one(tracking=15)
uom_po_id = fields.Many2one(tracking=15)
barcode = fields.Char(tracking=20)
default_code = fields.Char(tracking=30)
categ_id = fields.Many2one(tracking=40)
detailed_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)
purchase_ok = fields.Boolean(tracking=90)
active = fields.Boolean(tracking=100)
company_id = fields.Many2one(tracking=110)
barcode_type = fields.Char(compute='_compute_template_barcode_type')
# precompute=True doesn't work on product.template
# (works fine on product.product), probably because we don't depend
# on 'barcode'
@api.depends('product_variant_ids.barcode')
def _compute_template_barcode_type(self):
ppo = self.env['product.product']
for template in self:
barcode_type = False
if len(template.product_variant_ids) == 1:
barcode = template.product_variant_ids.barcode
barcode_type = ppo._get_barcode_type(barcode)
template.barcode_type = barcode_type