I want to create a module that depends on product_measurements but also adds the “length” fields to product.product (instead of relying on product.template).
At first I thought that I would just have to add the field to _no_template_field
but all scenarios fail with something like:
File ".../tests/scenario_production_priority.rst", line 142, in scenario_production_priority.rst
Failed example:
template.save()
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python3.9/doctest.py", line 1336, in __run
exec(compile(example.source, filename, "single",
File "<doctest scenario_production_priority.rst[85]>", line 1, in <module>
template.save()
File "/proteus/proteus/__init__.py", line 102, in newfunc
return self.func(owner, [instance], *args, **kwargs)
File "/proteus/proteus/__init__.py", line 847, in save
ids = proxy.create(values, context)
File "/proteus/proteus/config.py", line 203, in __call__
result = rpc.result(meth(*args, **kwargs))
File "/trytond/trytond/modules/product/product.py", line 256, in create
templates = super(Template, cls).create(vlist)
File "/trytond/trytond/model/modelsql.py", line 161, in wrapper
return func(cls, *args, **kwargs)
File "/trytond/trytond/model/modelsql.py", line 718, in create
field.set(cls, fname, *fargs)
File "/trytond/trytond/model/fields/one2many.py", line 287, in set
Target.create(to_create)
File "/trytond/trytond/modules/product/product.py", line 582, in create
products = super().create(vlist)
File "/trytond/trytond/model/modelsql.py", line 161, in wrapper
return func(cls, *args, **kwargs)
File "/home/albert/d/root-6.4/trytond/trytond/model/modelsql.py", line 726, in create
cls._validate(sub_records)
File "/trytond/trytond/model/modelstorage.py", line 91, in wrapper
return func(*args, **kwargs)
File "/trytond/trytond/model/modelstorage.py", line 1442, in _validate
value = getattr(record, field_name)
File "/trytond/trytond/model/fields/field.py", line 365, in __get__
return inst.__getattr__(self.name)
File "/trytond/trytond/model/modelstorage.py", line 1784, in __getattr__
read_data = self.read(list(index.keys()), list(ffields.keys()))
File "/trytond/trytond/model/modelsql.py", line 839, in read
cursor.execute(*from_.select(*columns.values(), where=where,
sqlite3.OperationalError: no such column: a.length_uom
If I add the __register__()
method and use pdb I see that the length fields are already created as Function fields when __register__()
is called (before calling super) so register will not create those fields in the database.
Am I missing something?