Hi guys,
I have a strange behavior where some fields get random unintended modifications (copying values from sibling records in an One2Many relationship. A few details of the models…
class Loan(Workflow, ModelSQL, ModelView):
"""Loan"""
__name__ = "innoproc.loan"
_history = True
number = fields.Char('Number', size=None, readonly=True, select=True)
...
conditions = fields.One2Many('innoproc.loan_condition', 'loan', 'Conditions', loading='eager', states={
'readonly': ~In(Eval('state', 'draft'), ['approved', 'conditions_loaded', 'conditions_doc_identified',
'conditions_submission', 'title_requested', 'insurance_requested',
'initial_submission', 'appraisal_requested'])
On the other hand the class Conditions…
class LoanCondition(ModelSQL, ModelView, LoanDemandMixin):
"""Loan Condition"""
__name__ = 'innoproc.loan_condition'
_history = True
name = fields.Char('Name', depends=['locked'], states={
'readonly': Eval('locked', False)
})
number = fields.Integer('Number', depends=['locked'], states={
'readonly': Eval('locked', False)
})
detail = fields.Text('Detail', depends=['locked'], states={
'readonly': Eval('locked', False)
})
documents = fields.One2Many('innoproc.condition_document', 'loan_condition', 'Documents', depends=['locked'],
states={'readonly': Eval('locked', False)
})
My problem is that sometimes “primitive” fields like name, number, and detail in some instances of LoanCondition get modified assuming values of other Condition instance (but I’ve never seen this behavior in One2Many fields like LoanCondition.documents in this case).
At some point, I thought that the problem was some kind of desynchronization between the backend and frontend (I’m using SAO), then I changed the conditions field to eager loading, but the problem remains.
My user interface is Loan-centric (meaning I do not have a Conditions window since all conditions are created/modified from the Loan window).
I suspect that the problem is somehow related to the concept of “active record” because I have the idea that the problem appears when I’m moving between the different Conditions in the loan (like if the frontend has an active record (Condition) different from the one that the backend “thinks” is the active one, triggering the change (but this is a theory only).
Have you ever faced a similar problem? Any clues on how to tackle this?