Manage products directly on category form

Closes #14811
This commit is contained in:
Cédric Krier
2026-04-24 23:31:34 +02:00
parent 3317d0849a
commit bd60a15973
8 changed files with 8 additions and 61 deletions
-6
View File
@@ -10,12 +10,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="name">category_form</field>
</record>
<record model="ir.ui.view" id="category_view_form_product">
<field name="model">product.category</field>
<field name="inherit" ref="product.category_view_form_product"/>
<field name="name">category_product_form</field>
</record>
<record model="ir.rule.group" id="rule_group_category_default">
<field name="name">Not accounting category</field>
<field name="model">product.category</field>
@@ -27,5 +27,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="customer_taxes" colspan="2"/>
<field name="supplier_taxes" colspan="2"/>
</page>
<page name="accounting_templates" col="1">
<field name="accounting_templates" widget="many2many"/>
</page>
</xpath>
</data>
@@ -1,8 +0,0 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="//field[@name='templates']" position="after">
<field name="accounting_templates" widget="many2many" colspan="2"/>
</xpath>
</data>
+1
View File
@@ -1,3 +1,4 @@
* Manage products directly on category form
Version 8.0.0 - 2026-04-20
--------------------------
+1 -15
View File
@@ -7,7 +7,7 @@ from sql.operators import Equal
from trytond.model import Exclude, ModelSQL, ModelView, fields, tree
from trytond.pool import Pool
from trytond.pyson import Eval, PYSONEncoder
from trytond.pyson import Eval
from trytond.tools import is_full_text, lstrip_wildcard
@@ -41,11 +41,6 @@ class Category(tree(separator=' / '), ModelSQL, ModelView):
'product.msg_category_code_unique'),
]
cls._order.insert(0, ('name', 'ASC'))
cls._buttons.update({
'add_products': {
'icon': 'tryton-add',
},
})
@classmethod
def default_code_readonly(cls):
@@ -80,15 +75,6 @@ class Category(tree(separator=' / '), ModelSQL, ModelView):
('code', operator, code_value, *extra),
]
@classmethod
@ModelView.button_action('product.act_category_product')
def add_products(cls, categories):
return {
'res_id': [categories[0].id if categories else None],
'pyson_domain': PYSONEncoder().encode(
[('id', '=', categories[0].id if categories else None)]),
}
@classmethod
def _code_sequence(cls):
pool = Pool()
-23
View File
@@ -22,13 +22,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="priority" eval="10"/>
<field name="name">category_form</field>
</record>
<record model="ir.ui.view" id="category_view_form_product">
<field name="model">product.category</field>
<field name="type">form</field>
<field name="priority" eval="20"/>
<field name="name">category_product_form</field>
</record>
<record model="ir.action.act_window" id="act_category_tree">
<field name="name">Categories</field>
<field name="res_model">product.category</field>
@@ -71,22 +64,6 @@ this repository contains the full copyright notices and license terms. -->
sequence="10"
id="menu_category_list"/>
<record model="ir.action.act_window" id="act_category_product">
<field name="name">Add products</field>
<field name="res_model">product.category</field>
</record>
<record model="ir.action.act_window.view" id="act_category_product_view1">
<field name="sequence" eval="10"/>
<field name="view" ref="category_view_form_product"/>
<field name="act_window" ref="act_category_product"/>
</record>
<record model="ir.model.button" id="category_add_products_button">
<field name="model">product.category</field>
<field name="name">add_products</field>
<field name="string">Add products</field>
</record>
<record model="ir.model.access" id="access_product_category">
<field name="model">product.category</field>
<field name="perm_read" eval="True"/>
+3 -1
View File
@@ -13,10 +13,12 @@ this repository contains the full copyright notices and license terms. -->
<label name="parent"/>
<field name="parent" colspan="3"/>
<button name="add_products" colspan="6"/>
<notebook colspan="6">
<page string="Children" col="1" id="childs">
<field name="childs"/>
</page>
<page name="templates" col="1">
<field name="templates"/>
</page>
</notebook>
</form>
@@ -1,8 +0,0 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form col="2">
<label name="rec_name"/>
<field name="rec_name" readonly="1"/>
<field name="templates" colspan="2"/>
</form>