I have a situation when shipments comes in, the user have to add some properties to it. This behavior worked in Tryton version 5.0 and 5.2, but not in 5.4 anymore. I think something has changed on the server side, but I cannot get my head around it what actually changed.
I extended the shipment.in
workflow with a wizard. This wizard get the shipment.id
and checks for certain products. This products are then added to a list and the user can walk through this list to add the properties to that particular product. To make âwalkingâ easier, the user uses a âNextâ button.
Below the fields:
products = fields.Many2Many('product.product', None, None,
'Products To Complete', required=True, readonly=True)
product = fields.Many2One('product.product', 'Current selected Product')
property_set = fields.Many2One('product.property.set', 'Property Set')
properties = fields.One2Many(
'shipment.in.addoption.add', 'product', 'Product Properties')
@fields.depends('product')
def on_change_product(self, name=None):
self.property_set = self.product.property_set.id
This works well, no problems so far. I can start the wizard and everything is correctly filled. The wizard form shows up, no error. When I now want to add a new property
I click on the â+â button of the One2Many field properties
I get the following error:
[...] ERROR trytond.protocols.dispatcher <class 'trytond.modules.my_extensions.shipment.AddProductPropertiesAdd'>.on_change_with_property_set(*({'product': {'attribute_set': 1, 'product': 1, 'id': -11}, 'id': -12}, {'client': '4e69e28f-3abe-419b-b951-6266b0275b48', 'warehouse': None, 'employee': None, 'company': 1, 'company.rec_name': 'testcompany', 'language': 'en', 'language_direction': 'ltr', 'groups': [4, 5, 1, 7, 8, 2, 26, 23, 20, 3, 6, 13, 15, 14, 18, 19, 16, 17, 10, 9, 11, 12, 25, 24, 21, 22], 'company_work_time': {'h': 3600, 'm': 60, 's': 1, 'Y': 6912000.0, 'M': 576000.0, 'w': 144000.0, 'd': 28800.0}, 'active_id': 1, 'active_ids': [1], 'active_model': 'stock.shipment.in', 'action_id': 306}), **{}) from admin@ipaddress//testone2many1/
Traceback (most recent call last):
File "/home/tryton54/lib/python3.6/site-packages/trytond/protocols/dispatcher.py", line 181, in _dispatch
= rpc.convert(obj, *args, **kwargs)
File "/home/tryton54/lib/python3.6/site-packages/trytond/rpc.py", line 81, in convert
args[self.instantiate] = instance(data)
File "/home/tryton54/lib/python3.6/site-packages/trytond/rpc.py", line 69, in instance
return obj(**data)
File "/home/tryton54/lib/python3.6/site-packages/trytond/model/model.py", line 255, in __init__
setattr(self, name, value)
File "/home/tryton54/lib/python3.6/site-packages/trytond/model/fields/many2one.py", line 108, in __set__
value = Target(**value)
File "/home/tryton54/lib/python3.6/site-packages/trytond/model/modelstorage.py", line 1392, in __init__
super(ModelStorage, self).__init__(id, **kwargs)
File "/home/tryton54/lib/python3.6/site-packages/trytond/model/model.py", line 255, in __init__
setattr(self, name, value)
AttributeError: 'product.product' object has no attribute 'product'
The fields of the properties are:
product = fields.Many2One('product.product', 'Current Product')
property_set = fields.Function(
fields.Many2One('product.property.set', 'Property Set'),
'on_change_with_property_set')
@fields.depends('product')
def on_change_with_property_set(self, name=None):
if self.product and self.product.property_set:
return self.product.property_set.id
I removed the rest of the fields to see where the error comes from.
I also added an extra field to the first set of fields like
current_contact = fields.Many2One('party.party', 'Current Contact')
The error then starts to complain about
AttributeError: 'product.product' object has no attribute 'current_contact'
I have changes basically everything but cannot get it to work. Any help is appreciated.