Compare commits
1 Commits
18-mig-com
...
14.0-add-p
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e12cca8dd0 |
@@ -33,6 +33,7 @@ This module has been written by Alexis de Lattre from Akretion <alexis.delattre@
|
||||
'views/product_template_view.xml',
|
||||
'views/product_product.xml',
|
||||
'views/product_category_view.xml',
|
||||
'views/product_attribute_view.xml',
|
||||
],
|
||||
'installable': True,
|
||||
}
|
||||
|
||||
@@ -3,3 +3,4 @@ from . import product_template
|
||||
from . import product_supplierinfo
|
||||
from . import product_pricelist
|
||||
from . import product_category
|
||||
from . import product_attribute
|
||||
|
||||
27
product_usability/models/product_attribute.py
Normal file
27
product_usability/models/product_attribute.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# Copyright (C) 2022 Akretion (<http://www.akretion.com>).
|
||||
# @author Kévin Roche <kevin.roche@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
class ProductAttribute(models.Model):
|
||||
_inherit = "product.attribute"
|
||||
|
||||
values_count = fields.Integer(compute="_compute_values_count")
|
||||
|
||||
@api.depends("value_ids")
|
||||
def _compute_values_count(self):
|
||||
for attr in self:
|
||||
attr.values_count = len(attr.value_ids)
|
||||
|
||||
def show_values_ids(self):
|
||||
return {
|
||||
"name": "Attributes Lines",
|
||||
"type": "ir.actions.act_window",
|
||||
"res_id": self.id,
|
||||
"view_mode": "tree",
|
||||
"res_model": "product.attribute.value",
|
||||
"view_id":self.env.ref("product_usability.product_attribute_value_view_tree").id,
|
||||
"target": "current",
|
||||
"domain": [("id", "in", self.value_ids.ids)],
|
||||
}
|
||||
38
product_usability/views/product_attribute_view.xml
Normal file
38
product_usability/views/product_attribute_view.xml
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="product_attribute_values_button" model="ir.ui.view">
|
||||
<field name="model">product.attribute</field>
|
||||
<field name="inherit_id" ref="product.product_attribute_view_form" />
|
||||
<field name="arch" type="xml">
|
||||
<group name="main_fields" position='before'>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<button
|
||||
name="show_values_ids"
|
||||
type="object"
|
||||
class="oe_stat_button"
|
||||
icon="fa-tasks"
|
||||
>
|
||||
<field
|
||||
name="values_count"
|
||||
widget="statinfo"
|
||||
string="Attribute Values"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="product_attribute_value_view_tree">
|
||||
<field name="name">product.attribute.value.view.tree</field>
|
||||
<field name="model">product.attribute.value</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Attributes Values">
|
||||
<field name="name"/>
|
||||
<field name="is_custom"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user