[MIG] product_usability to v14

This commit is contained in:
Alexis de Lattre
2020-12-02 00:23:27 +01:00
parent f3782cfa2b
commit e505e7e07f
17 changed files with 139 additions and 307 deletions

View File

@@ -1,7 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import product
from . import product_product
from . import product_template
from . import product_supplierinfo
from . import product_price_history
from . import pricelist
from . import product_pricelist

View File

@@ -1,11 +0,0 @@
# © 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields
class ProductPricelist(models.Model):
_inherit = 'product.pricelist'
company_id = fields.Many2one(
default=lambda self: self.env['res.company']._company_default_get())

View File

@@ -1,46 +0,0 @@
# © 2015-2016 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 models, fields
class ProductProduct(models.Model):
_inherit = 'product.product'
default_code = fields.Char(
track_visibility='onchange',
copy=False)
barcode = fields.Char(
track_visibility='onchange',
copy=False)
weight = fields.Float(
track_visibility='onchange')
active = fields.Boolean(
track_visibility='onchange')
price_history_ids = fields.One2many(
comodel_name='product.price.history',
inverse_name='product_id',
string='Product Price History')
_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!')]
def show_product_price_history(self):
self.ensure_one()
action = self.env.ref(
'product_usability.product_price_history_action').read()[0]
action['domain'] = [('product_id', '=', self.id)]
return action

View File

@@ -1,16 +0,0 @@
# © 2015-2016 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 models, fields
class ProductPriceHistory(models.Model):
_inherit = 'product.price.history'
company_currency_id = fields.Many2one(
related='company_id.currency_id',
readonly=True,
compute_sudo=True,
string='Company Currency')

View File

@@ -0,0 +1,11 @@
# Copyright 2017-2020 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,28 @@
# Copyright 2015-2020 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 models, fields
class ProductProduct(models.Model):
_inherit = 'product.product'
default_code = fields.Char(copy=False)
# track_visibility='onchange',
# barcode = fields.Char(track_visibility='onchange',
# weight = fields.Float(track_visibility='onchange')
# active = fields.Boolean(track_visibility='onchange')
_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!')]

View File

@@ -1,13 +1,12 @@
# © 2015-2016 Akretion (http://www.akretion.com)
# Copyright 2015-2020 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 models, fields
from odoo import fields, models
class ProductSupplierinfo(models.Model):
_inherit = 'product.supplierinfo'
name = fields.Many2one(
domain=[('supplier', '=', True), ('parent_id', '=', False)])
name = fields.Many2one(domain=[('parent_id', '=', False)])

View File

@@ -1,4 +1,4 @@
# © 2015-2016 Akretion (http://www.akretion.com)
# Copyright 2015-2020 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).
@@ -9,32 +9,23 @@ from odoo import models, fields
class ProductTemplate(models.Model):
_inherit = 'product.template'
name = fields.Char(
track_visibility='onchange')
# name = fields.Char(
# track_visibility='onchange')
type = fields.Selection(
track_visibility='onchange')
# type = fields.Selection(
# track_visibility='onchange')
categ_id = fields.Many2one(
track_visibility='onchange')
# categ_id = fields.Many2one(
# track_visibility='onchange')
list_price = fields.Float(
track_visibility='onchange')
# list_price = fields.Float(
# track_visibility='onchange')
sale_ok = fields.Boolean(
track_visibility='onchange')
# sale_ok = fields.Boolean(
# track_visibility='onchange')
purchase_ok = fields.Boolean(
track_visibility='onchange')
# purchase_ok = fields.Boolean(
# track_visibility='onchange')
active = fields.Boolean(
track_visibility='onchange')
def show_product_price_history(self):
self.ensure_one()
products = self.env['product.product'].search(
[('product_tmpl_id', '=', self._context['active_id'])])
action = self.env.ref(
'product_usability.product_price_history_action').read()[0]
action['domain'] = [('product_id', 'in', products.ids)]
return action
# active = fields.Boolean(
# track_visibility='onchange')