Use proteus to access custom field

Suppose I have defined a new field in the product.product class as

description2 = fields.Text("Description2", translate=True)

Now, if I create a database with the above modification, create a product, run Proteus, and try to access the new field as follows:

Product = Model.get('product.product')
all_vars = Product.find()
var1 = all_vars[0]
var1.description2

I get:

AttributeError: 'product.product' object has no attribute 'description2'

How can I get Proteus to access description2 ?

You have nothing to do for proteus. So this error means that the customization is not correctly setup.

The answer is the following:
I had installed trytond in a folder outside my virtual environment folder (so I could keep the customized modules separate, and the rest of the stuff in the env… folder).

When I opened Spyder (my IDE) in that virtual environment, I had to set my working directory to the trytond installation folder (outside the virtual env.) for it to work properly.

@ced For completeness, I should have said that I am running the following code:

from proteus import config, Model, Wizard, Report
cfg = config.set_trytond(database='test2' , config_file='C:\\Users\\user\\Desktop\\trytond\\trytond-6.0.2\\etc\\trytond.conf')
Product = Model.get('product.product')
all_vars = Product.find()
var1 = all_vars[0]
var1.description2

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.