[MIG] product_usability_akretion to v18
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
from . import product_product
|
||||
from . import product_template
|
||||
from . import product_supplierinfo
|
||||
from . import product_pricelist
|
||||
from . import product_category
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2022 Akretion (https://www.akretion.com).
|
||||
# Copyright 2022-2024 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).
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# 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)
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2015-2022 Akretion (http://www.akretion.com)
|
||||
# Copyright 2015-2024 Akretion (https://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).
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2015-2022 Akretion (http://www.akretion.com)
|
||||
# Copyright 2015-2024 Akretion (https://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).
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user