details: https://code.tryton.org/tryton/commit/5ab2d2f91842
branch: default
user: Maxime Richez <[email protected]>
date: Thu May 07 11:19:56 2026 +0200
description:
Display products used by customs category
Closes #14770
diffstat:
modules/customs/product.py | 28 ++++++++++++++++++++++++++++
modules/customs/tryton.cfg | 2 ++
2 files changed, 30 insertions(+), 0 deletions(-)
diffs (55 lines):
diff -r a463be917f25 -r 5ab2d2f91842 modules/customs/product.py
--- a/modules/customs/product.py Tue May 12 09:33:32 2026 +0000
+++ b/modules/customs/product.py Thu May 07 11:19:56 2026 +0200
@@ -1,5 +1,7 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
+from sql import Null
+
from trytond.model import ModelSQL, ModelView, fields, sequence_ordered
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Bool, Eval, Or
@@ -160,6 +162,32 @@
return callback
+class TemplateCustomsCategory(ModelSQL):
+ __name__ = 'product.template-product.category.customs'
+ template = fields.Many2One('product.template', 'Template')
+ category = fields.Many2One('product.category', 'Category')
+
+ @classmethod
+ def table_query(cls):
+ pool = Pool()
+ Template = pool.get('product.template')
+ template = Template.__table__()
+ return template.select(
+ template.id.as_('id'),
+ template.id.as_('template'),
+ template.customs_category.as_('category'),
+ where=template.customs_category != Null)
+
+
+class TemplateCategoryAll(metaclass=PoolMeta):
+ __name__ = 'product.template-product.category.all'
+
+ @classmethod
+ def union_models(cls):
+ return super().union_models() + [
+ 'product.template-product.category.customs']
+
+
class Product_TariffCode(sequence_ordered(), ModelSQL, ModelView):
__name__ = 'product-customs.tariff.code'
product = fields.Reference('Product', selection=[
diff -r a463be917f25 -r 5ab2d2f91842 modules/customs/tryton.cfg
--- a/modules/customs/tryton.cfg Tue May 12 09:33:32 2026 +0000
+++ b/modules/customs/tryton.cfg Thu May 07 11:19:56 2026 +0200
@@ -20,5 +20,7 @@
customs.AgentSelection
product.Category
product.Template
+ product.TemplateCustomsCategory
+ product.TemplateCategoryAll
product.Product_TariffCode
product.Product