I have below code:
class RAGQuotationReportForm(ModelView):
'RAG Quotation Report Start'
__name__ = 'ltl.crm.rag.quotation.report.form'
quotation = fields.Many2One('ltl.crm.rag.quotation', 'Quotation', required=True)
subject = fields.Char('Subject', readonly=True)
to_company = fields.Char('To Company', readonly=True)
to_company_address = fields.Many2One('ltl.company.address', 'To Company Address',
domain=[
('company', '=', Eval('company_id'))
],
)
company_id = fields.Function(fields.Many2One('ltl.company', 'Company ID'),'get_company_id')
def get_company_id(self, name):
if self.quotation:
return self.quotation.proposal.client.company
else:
return None
My objective is to show a list of Company’s addresses, based on selected Company (which the quotation belongs to).
My steps:
- User select a quotation from Many2One selection
- Then select a company address from Many2One selection, with domain restriction based on selected quotation’s company.
- So I point the Eval to a function field → company_id that called selected quotation’s company
But when I do console logging at CompanyAddress class, what I got is like below:
INFO:trytond.modules.ltl_company.model.company_address:>>>>>>>>>>>>>> [['company', '=', None]] [company_address.py:46]
The company_id field Function seems doesn’t work. Does anybody knows how the right way to do this?
Bromo