Hi, although making modules in tryton for a long time, I am sort of stuck with inheritance and I have already spend over 2 days trying to solve a strange error and I need help.
I created a Module for recording Orders and in it I created a module to record an Order. The entry in this order is created by a wizard. This is live and running as expected.
Now I am developing another module to record the payments, and I have inherited the Order model. After inheritance and installing another module, when I run the wizard to create the order, it is giving the error -
AttributeError: type object ‘aiims.order’ has no attribute ‘_fields’
If I comment out the inherited class in the payments module, then wizard runs fine. So I know that there is some issue with the inheritance.
class Order(metaclass=PoolMeta):
__name__ = "aiims.order"
payments = fields.One2Many(
'order.pay_order', 'order', 'Payments'
)
payment_status = fields.Selection(
[
('unpaid', 'Unpaid'),
('partially_paid', 'Partially Paid'),
('paid', 'Paid')
], 'Payment Status', readonly=True
)
@classmethod
def __setup__(cls):
super(Order, cls).__setup__()
cls._buttons.update({
'generate_payment': {
'invisible': Eval('payment_status') == 'paid',
}
})
I have already done inheritance and overriding numerous times and I am not able to find any issue here. Still I am getting this error.
Traceback (most recent call last):
File "/.../trytond/protocols/dispatcher.py", line 176, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
File "/.../trytond/wizard/wizard.py", line 287, in execute
return wizard._execute(state_name)
File "/.../trytond/wizard/wizard.py", line 318, in _execute
result = self._execute(transition())
File "/.../python3.6/site-packages/trytond_order-5.0.0-py3.6.egg/trytond/modules/order/order.py", line 812, in transition_next_
"reference_num": order_temp.reference_num,
File "//.../trytond/model/modelsql.py", line 147, in wrapper
return func(cls, *args, **kwargs)
File "/.../trytond/model/modelsql.py", line 564, in create
for f in cls._fields.keys():
AttributeError: type object 'aiims.order' has no attribute '_fields'
More Info -
On checking the attributes list of the cls object in setup method, at the time of starting the server, it was found that _fields and _defaults are the 2 attributes that were found to be missing. (not sure if this info is relevant)
I have checked it on different systems, and the error is same, so I know that there is some issue with my code.
Tryton Server version - 5.0.35
Python version - 3.6.9
Thanks in advance for the help.