diff --git a/product_usability/__init__.py b/product_usability/__init__.py new file mode 100644 index 0000000..fe50f8f --- /dev/null +++ b/product_usability/__init__.py @@ -0,0 +1,3 @@ + +from . import product +from . import pricelist diff --git a/product_usability/__manifest__.py b/product_usability/__manifest__.py new file mode 100644 index 0000000..f37703c --- /dev/null +++ b/product_usability/__manifest__.py @@ -0,0 +1,34 @@ +# © 2015-2016 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +{ + 'name': 'Product Usability', + 'version': '12.0.1.0.0', + 'category': 'Product', + 'license': 'AGPL-3', + 'summary': 'Small usability enhancements to the product module', + 'description': """ +Product Usability +================= + +The usability enhancements include: + +* show the object product.price.history in the product template form view + +* wider name field in product form view + +* hide description field on product (description_sale must be use instead of description) + +This module has been written by Alexis de Lattre from Akretion . + """, + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'depends': ['product'], + 'data': [ + 'security/product_security.xml', + 'product_view.xml', + ], + 'installable': True, +} diff --git a/product_usability/pricelist.py b/product_usability/pricelist.py new file mode 100644 index 0000000..c87dd16 --- /dev/null +++ b/product_usability/pricelist.py @@ -0,0 +1,11 @@ +# © 2017 Akretion (Alexis de Lattre ) +# 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()) diff --git a/product_usability/product.py b/product_usability/product.py new file mode 100644 index 0000000..dfa1e13 --- /dev/null +++ b/product_usability/product.py @@ -0,0 +1,73 @@ + +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models, fields + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + name = fields.Char(track_visibility='onchange') + type = fields.Selection(track_visibility='onchange') + categ_id = fields.Many2one(track_visibility='onchange') + list_price = fields.Float(track_visibility='onchange') + sale_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['ir.actions.act_window'].for_xml_id( + 'product_usability', 'product_price_history_action') + action.update({ + 'domain': "[('id', 'in', %s)]" % products.ids, + }) + return action + + +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( + 'product.price.history', '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['ir.actions.act_window'].for_xml_id( + 'product_usability', 'product_price_history_action') + action.update({ + 'domain': "[('product_id', '=', %d)]" % self.ids[0], + }) + return action + + +class ProductSupplierinfo(models.Model): + _inherit = 'product.supplierinfo' + + name = fields.Many2one( + domain=[('supplier', '=', True), ('parent_id', '=', False)]) + + +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') diff --git a/product_usability/product_view.xml b/product_usability/product_view.xml new file mode 100644 index 0000000..f80430d --- /dev/null +++ b/product_usability/product_view.xml @@ -0,0 +1,220 @@ + + + + + + + + + product.price.history.form + product.price.history + +
+ + + + + + + +
+
+
+ + + product.price.history.tree + product.price.history + + + + + + + + + + + + + product.price.history.search + product.price.history + + + + + + + + + + + + + Product Price History + product.price.history + tree,form + {'product_price_history_main_view': True} + + + + + + + usability.product.template.form + product.template + + + +