# Adding fields to product.product that already exist in product.template

**URL:** https://discuss.tryton.org/t/adding-fields-to-product-product-that-already-exist-in-product-template/6254
**Category:** Developer
**Created:** [June 9, 2023, 10:54am UTC](https://discuss.tryton.org/t/adding-fields-to-product-product-that-already-exist-in-product-template/6254 "2023-06-09T10:54:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![albert](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/albert/32/21_2.png) [@albert](https://discuss.tryton.org/u/albert)
#### Post date: [June 9, 2023, 10:54am UTC](https://discuss.tryton.org/t/adding-fields-to-product-product-that-already-exist-in-product-template/6254/1 "2023-06-09T10:54:22Z")

</div>

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:

```auto
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?

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [June 9, 2023, 11:05am UTC](https://discuss.tryton.org/t/adding-fields-to-product-product-that-already-exist-in-product-template/6254/2 "2023-06-09T11:05:59Z")

</div>

You need to add the field definition on product\_product and override `_no_template_field` to avoid overriding the definition of your custom field.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [June 9, 2023, 11:39am UTC](https://discuss.tryton.org/t/adding-fields-to-product-product-that-already-exist-in-product-template/6254/3 "2023-06-09T11:39:51Z")

</div>

see [Not possible to redefine product field (#10322) · Issues · Tryton / Tryton · GitLab](https://foss.heptapod.net/tryton/tryton/-/issues/10322)
