documentation icon indicating copy to clipboard operation
documentation copied to clipboard

Invalid example in Chapter 12

Open eximius313 opened this issue 2 months ago • 2 comments

Chapter 12 gives example:

Image

which links to this code:

Image

but it throws exception:

prop = self.env['estate_property'].browse(vals_list['property_id'])
~~~~~~~~~^^^^^^^^^^^^^^^
TypeError: list indices must be integers or slices, not str

eximius313 avatar Oct 26 '25 18:10 eximius313

This is because vals_list is:

estate_property_offer: [{'price': 17, 'partner_id': 1, 'validity': 7, 'validity_date': '2025-11-02', 'property_id': 1}]

So, vals_list[0]['property_id'] solves the problem, but it's odd...

Domain

In Chapter 12, the Exercise says to Add a domain to the field to inherited view:

Image

which is described later in the chapter, so it should be in the second Exercise. Additionally - please describe how to add domain to a field, because so far we've added domain to action: of filter_domain:

<search string="Test">
    <field name="description" string="Name and description"
           filter_domain="['|', ('name', 'ilike', self), ('description', 'ilike', self)]"/>
</search>

both in Chapter 11

eximius313 avatar Oct 26 '25 19:10 eximius313

Also - please clarify that the class name of inherited model must be exactly ResUsers and not "InheritedResUsers" or "InheritedSalesPerson" Otherwise an exception is thrown:

File "/usr/lib/python3/dist-packages/odoo/orm/fields.py", line 544, in setup
self.setup_nonrelated(model)
File "/usr/lib/python3/dist-packages/odoo/orm/fields_relational.py", line 1302, in setup_nonrelated
raise TypeError(msg % (self, field))
TypeError: Many2many fields inherited.sales.person.company_ids and res.users.company_ids use the same table and columns

eximius313 avatar Oct 26 '25 20:10 eximius313