Merge pull request #80 from akretion/12.0-mig-product_usability
12.0 mig product usability
This commit is contained in:
3
product_usability/__init__.py
Normal file
3
product_usability/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
from . import product
|
||||
from . import pricelist
|
||||
34
product_usability/__manifest__.py
Normal file
34
product_usability/__manifest__.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# © 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).
|
||||
|
||||
|
||||
{
|
||||
'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 <alexis.delattre@akretion.com>.
|
||||
""",
|
||||
'author': 'Akretion',
|
||||
'website': 'http://www.akretion.com',
|
||||
'depends': ['product'],
|
||||
'data': [
|
||||
'security/product_security.xml',
|
||||
'product_view.xml',
|
||||
],
|
||||
'installable': True,
|
||||
}
|
||||
11
product_usability/pricelist.py
Normal file
11
product_usability/pricelist.py
Normal file
@@ -0,0 +1,11 @@
|
||||
# © 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())
|
||||
73
product_usability/product.py
Normal file
73
product_usability/product.py
Normal file
@@ -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')
|
||||
220
product_usability/product_view.xml
Normal file
220
product_usability/product_view.xml
Normal file
@@ -0,0 +1,220 @@
|
||||
<?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="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="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'}"/>
|
||||
</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>
|
||||
|
||||
<!--
|
||||
<menuitem id="product_price_history_menu" action="product_price_history_action"
|
||||
parent="product.prod_config_main" sequence="55"/> -->
|
||||
|
||||
<!-- 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>
|
||||
<!-- Don't make it too big, othesize computers with small resolutions
|
||||
will see the product name + image under the block of buttons -->
|
||||
<div class="oe_title" position="attributes">
|
||||
<attribute name="style">width: 650px;</attribute>
|
||||
</div>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- It also adds on 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>
|
||||
<field name="inherit_id" ref="product.product_template_search_view" />
|
||||
<field name="arch" type="xml">
|
||||
<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>
|
||||
|
||||
|
||||
<!-- 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>
|
||||
<field name="inherit_id" ref="product.product_product_tree_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="lst_price" position="after">
|
||||
<field name="currency_id" invisible="1"/>
|
||||
</field>
|
||||
<field name="lst_price" position="attributes">
|
||||
<attribute name="widget">monetary</attribute>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- product.pricelist -->
|
||||
<record id="product_pricelist_view_tree" model="ir.ui.view">
|
||||
<field name="name">usability.product.pricelist.tree</field>
|
||||
<field name="model">product.pricelist</field>
|
||||
<field name="inherit_id" ref="product.product_pricelist_view_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="currency_id" position="after">
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</field>
|
||||
</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>
|
||||
|
||||
<!-- 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="price" position="after">
|
||||
<field name="currency_id" groups="base.group_multi_currency"/>
|
||||
</field>
|
||||
<field name="min_qty" position="after">
|
||||
<field name="product_uom" groups="product.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>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
17
product_usability/security/product_security.xml
Normal file
17
product_usability/security/product_security.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?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>
|
||||
Reference in New Issue
Block a user