Lucas
(Lucas)
December 15, 2020, 1:54am
1
Hello, there is a field of
TYPES = [
(‘goods’, ‘Goods’),
(‘assets’, ‘Assets’),
(‘service’, ‘Service’),
]
that is declared as a class field, which is not defined within any models. I would like to understand on how to override this field and to add new values in, thanks!
Alnus
(Alnus)
December 15, 2020, 2:49am
2
Hello @Lucas welcome to the Tryton community
Goods, Assets and Service are part of Tryton business logic for this reason adding or making changes to these names can alter the operation of modules such as Sale, Purchase, Account_Assets among others.
These are modeled in the “class Template” in http://hg.tryton.org/modules/product/file/tip/product.py#l58 using https://docs.tryton.org/projects/server/en/latest/ref/models/fields.html?highlight=field#selection .
What would be the changes in concrete for Types?
Lucas
(Lucas)
December 15, 2020, 3:04am
3
Hello @Alnus , thanks for the reply. I was considering to add a 4th field so as to allow for any additional filler needed in the future.
Would this mean that I have to add the 4th entry in the
type = fields.Selection(TYPES, “Type”, required=True) by overriding it?
joseagrc
(José Arturo García)
December 15, 2020, 3:23am
4
Hi, @Lucas , try this:
class Template(metaclass=PoolMeta):
name = “product.template”
@classmethod
def __setup__(cls):
super().__setup__()
for new_type in [
('new_item', 'New Item')]:
if new_type not in cls.type.selection:
cls.type.selection.append(new_type)
2 Likes
system
(system)
Closed
January 14, 2021, 5:19am
6
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.