[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,3 +1 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models

View File

@@ -1,11 +1,11 @@
# © 2015-2016 Akretion (http://www.akretion.com)
# Copyright 2015-2020 Akretion France (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Product Usability',
'version': '12.0.1.0.0',
'version': '14.0.1.0.0',
'category': 'Product',
'license': 'AGPL-3',
'summary': 'Small usability enhancements to the product module',
@@ -27,12 +27,11 @@ This module has been written by Alexis de Lattre from Akretion <alexis.delattre@
'website': 'http://www.akretion.com',
'depends': ['product'],
'data': [
'security/product_security.xml',
'views/product_supplierinfo_view.xml',
'views/product_price_history_view.xml',
'views/product_pricelist_view.xml',
'views/product_pricelist_item.xml',
'views/product_template_view.xml',
'views/product_view.xml',
'views/product_product.xml',
],
'installable': False,
'installable': True,
}

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')

View File

@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2015-2016 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).
-->
<odoo noupdate="1">
<record id="product_price_history_rule" model="ir.rule">
<field name="name">Product price history multi-company</field>
<field name="model_id" ref="product.model_product_price_history"/>
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
</record>
</odoo>

View File

@@ -1,65 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2015-2016 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).
-->
<odoo>
<!-- product.price.history -->
<record id="product_price_history_form" model="ir.ui.view">
<field name="name">product.price.history.form</field>
<field name="model">product.price.history</field>
<field name="arch" type="xml">
<form string="Product Price History">
<group name="main">
<field name="product_id" invisible="not context.get('product_price_history_main_view')"/>
<field name="datetime"/>
<field name="cost" widget="monetary" options="{'currency_field': 'company_currency_id'}"/>
<field name="create_uid"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="company_currency_id" invisible="1"/>
</group>
</form>
</field>
</record>
<record id="product_price_history_tree" model="ir.ui.view">
<field name="name">product.price.history.tree</field>
<field name="model">product.price.history</field>
<field name="arch" type="xml">
<tree string="Product Price History" editable="bottom">
<field name="product_id" invisible="not context.get('product_price_history_main_view')"/>
<field name="datetime"/>
<field name="cost" widget="monetary" options="{'currency_field': 'company_currency_id'}"/>
<field name="create_uid"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="company_currency_id" invisible="1"/>
</tree>
</field>
</record>
<record id="product_price_history_search" model="ir.ui.view">
<field name="name">product.price.history.search</field>
<field name="model">product.price.history</field>
<field name="arch" type="xml">
<search string="Search Product Price History">
<field name="product_id"/>
<group string="Group By" name="groupby">
<filter name="product_groupby" string="Product" context="{'group_by': 'product_id'}"/>
<filter name="datetime_groupby" string="Date" context="{'group_by': 'datetime:month'}"/>
<filter name="create_uid_groupby" string="Created by" context="{'group_by': 'create_uid'}"/>
</group>
</search>
</field>
</record>
<record id="product_price_history_action" model="ir.actions.act_window">
<field name="name">Product Price History</field>
<field name="res_model">product.price.history</field>
<field name="view_mode">tree,form</field>
<field name="context">{'product_price_history_main_view': True}</field>
</record>
</odoo>

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2015-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).
-->
<odoo>
<record id="product_pricelist_item_view_search" model="ir.ui.view">
<field name="name">product.pricelist.item.search</field>
<field name="model">product.pricelist.item</field>
<field name="inherit_id" ref="product.product_pricelist_item_view_search"/>
<field name="arch" type="xml">
<field name="pricelist_id" position="after">
<field name="product_tmpl_id"/>
<field name="product_id"/>
<field name="categ_id"/>
</field>
<filter name="groupby_vendor" position="after">
<filter name="applied_on_groupby" string="Apply On" context="{'group_by': 'applied_on'}"/>
<filter name="base_on_groupby" string="Based On" context="{'group_by': 'base'}"/>
<filter name="compute_price_groupby" string="Compute Price" context="{'group_by': 'compute_price'}"/>
<filter name="currency_groupby" string="Currency" context="{'group_by': 'currency_id'}"/>
</filter>
</field>
</record>
<record id="product_pricelist_item_form_view" model="ir.ui.view">
<field name="name">usability.product.pricelist.item.form</field>
<field name="model">product.pricelist.item</field>
<field name="inherit_id" ref="product.product_pricelist_item_form_view"/>
<field name="arch" type="xml">
<field name="pricelist_id" position="attributes">
<attribute name="invisible">not context.get('product_pricelist_item_main_view')</attribute>
</field>
</field>
</record>
</odoo>

View File

@@ -1,65 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2015-2016 Akretion (http://www.akretion.com/)
Copyright 2015-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).
-->
<odoo>
<!-- product.pricelist -->
<record id="product_pricelist_view_tree" model="ir.ui.view">
<field name="name">usability.product.pricelist.tree</field>
<record id="pricelist_item_fullscreen_action" model="ir.actions.act_window">
<field name="name">Pricelists Items</field>
<field name="res_model">product.pricelist.item</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('pricelist_id', '=', active_id)]</field>
<field name="context">{'product_pricelist_item_main_view': True}</field>
</record>
<record id="product_pricelist_view" model="ir.ui.view">
<field name="name">usability.product.pricelist.form</field>
<field name="model">product.pricelist</field>
<field name="inherit_id" ref="product.product_pricelist_view_tree"/>
<field name="inherit_id" ref="product.product_pricelist_view"/>
<field name="arch" type="xml">
<field name="currency_id" position="after">
<field name="company_id" groups="base.group_multi_company"/>
</field>
<div class="oe_title" position="before">
<div name="button_box" class="oe_button_box">
<button name="%(pricelist_item_fullscreen_action)d"
class="oe_stat_button"
icon="fa-building-o"
type="action"
help="List view of pricelist items">
<div class="o_form_field o_stat_info">
<span class="o_stat_text">Lines Fullscreen</span>
</div>
</button>
</div>
</div>
</field>
</record>
<!-- product.pricelist.item -->
<record id="product_pricelist_item_search" model="ir.ui.view">
<field name="name">usability.product.pricelist.item.search</field>
<field name="model">product.pricelist.item</field>
<field name="arch" type="xml">
<search string="Search Pricelist Items">
<field name="pricelist_id"/>
<field name="product_tmpl_id"/>
<field name="product_id"/>
<field name="categ_id"/>
<group string="Group By" name="groupby">
<filter name="pricelist_groupby" string="Pricelist" context="{'group_by': 'pricelist_id'}"/>
<filter name="applied_on_groupby" string="Apply On" context="{'group_by': 'applied_on'}"/>
<filter name="base_on_groupby" string="Based On" context="{'group_by': 'base'}"/>
<filter name="compute_price_groupby" string="Compute Price" context="{'group_by': 'compute_price'}"/>
<filter name="currency_groupby" string="Currency" context="{'group_by': 'currency_id'}"/>
</group>
</search>
</field>
</record>
<record id="product_pricelist_item_form_view" model="ir.ui.view">
<field name="name">usability.product.pricelist.item.form</field>
<field name="model">product.pricelist.item</field>
<field name="inherit_id" ref="product.product_pricelist_item_form_view"/>
<field name="arch" type="xml">
<field name="applied_on" position="before">
<field name="pricelist_id" invisible="not context.get('product_pricelist_item_main_view')"/>
</field>
</field>
</record>
<record id="product_pricelist_item_tree_view" model="ir.ui.view">
<field name="name">usability.product.pricelist.item.tree</field>
<field name="model">product.pricelist.item</field>
<field name="inherit_id" ref="product.product_pricelist_item_tree_view"/>
<field name="arch" type="xml">
<field name="name" position="before">
<field name="pricelist_id" invisible="not context.get('product_pricelist_item_main_view')"/>
</field>
</field>
</record>
</odoo>

View File

@@ -1,13 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2015-2016 Akretion (http://www.akretion.com/)
Copyright 2015-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).
-->
<odoo>
<!-- product.product -->
<record id="product_product_tree_view" model="ir.ui.view">
<field name="name">usability.product.product.tree</field>
<field name="model">product.product</field>

View File

@@ -1,36 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2015-2016 Akretion (http://www.akretion.com/)
Copyright 2015-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).
-->
<odoo>
<!-- product.supplierinfo -->
<record id="product_supplierinfo_tree_view" model="ir.ui.view">
<field name="model">product.supplierinfo</field>
<field name="inherit_id" ref="product.product_supplierinfo_tree_view"/>
<field name="arch" type="xml">
<field name="product_tmpl_id" position="after">
<field name="product_name"/>
<field name="product_code" string="Supplier Code"/>
</field>
<field name="currency_id" position="after">
<field name="delay"/>
</field>
<field name="min_qty" position="after">
<field name="product_uom" groups="uom.group_uom"/>
</field>
</field>
</record>
<record id="product_supplierinfo_search_view" model="ir.ui.view">
<field name="model">product.supplierinfo</field>
<field name="inherit_id" ref="product.product_supplierinfo_search_view"/>
<field name="arch" type="xml">
<field name="product_tmpl_id" position="after">
<field name="product_code" string="Product Supplier Code"/>
<field name="product_code"/>
</field>
</field>
</record>

View File

@@ -1,25 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2015-2016 Akretion (http://www.akretion.com/)
Copyright 2015-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).
-->
<odoo>
<!-- product.template -->
<record id="product_template_form_view" model="ir.ui.view">
<field name="name">usability.product.template.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view" />
<field name="arch" type="xml">
<field name="standard_price" class="oe_inline" position="after">
<button name="show_product_price_history" class="oe_inline oe_link" type="object" string="Show History" context="{'active_id': active_id}"/>
</field>
</field>
</record>
<!-- It also adds on product.product search view -->
<!-- It also updates product.product search view -->
<record id="product_template_search_view" model="ir.ui.view">
<field name="name">usability.product.template.search</field>
<field name="model">product.template</field>
@@ -28,29 +16,6 @@
<field name="categ_id" position="after">
<field name="seller_ids" string="Supplier" filter_domain="[('seller_ids.name', 'ilike', self)]"/>
</field>
<field name="pricelist_id" position="after">
<group string="Group By" name="groupby">
<filter name="categ_groupby" string="Internal Category" context="{'group_by': 'categ_id'}"/>
<filter name="type_groupby" string="Type" context="{'group_by': 'type'}"/>
</group>
</field>
</field>
</record>
<record id="product_template_tree_view" model="ir.ui.view">
<field name="name">usability.product.template.tree</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_tree_view"/>
<field name="arch" type="xml">
<field name="list_price" position="after">
<field name="currency_id" invisible="1"/>
</field>
<field name="list_price" position="attributes">
<attribute name="widget">monetary</attribute>
</field>
<field name="standard_price" position="attributes">
<attribute name="widget">monetary</attribute>
</field>
</field>
</record>