Hi @oscarQ thank you for the solution
Now I have another challenge, my wizard form code is like below:
class RAGQuotationReportForm(ModelView):
'Download RAG Quotation Form'
__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.Char('To Company Address', readonly=True)
attn_to_name = fields.Char('Attn To Name', readonly=True)
attn_to_email = fields.Char('Attn To Email', readonly=True)
attn_to_phone = fields.Char('Attn To Phone', readonly=True)
quot_reff = fields.Char('Ref No', readonly=True)
quot_no = fields.Char('No', readonly=True)
quot_date = fields.Date('Date', readonly=True)
quot_term = fields.Char('Term')
quot_inquiry = fields.Selection([
(None, 'Select..'),
('By Email', 'By Email'),
('By Phone', 'By Phone'),
('By Document', 'By Document'),
], 'Inquiry', sort=False, states={
'readonly': Eval('quotation', None) == None,
})
quot_scenario = fields.Selection([
(None, 'Select..'),
('12M', '12 Months'),
('6M', '6 Months'),
('3M', '3 Months'),
('Custom', 'Custom')
], 'Pricing Scenario', sort=False, states={
'readonly': Eval('quotation', None) == None,
}, required=True)
@fields.depends('quotation')
def on_change_quotation(self):
if self.quotation:
self.subject = self.quotation.subject
self.to_company = self.quotation.proposal.client.company.name
self.to_company_address = self.quotation.proposal.requestor.address
self.attn_to_name = self.quotation.proposal.requestor.party.name
self.attn_to_email = self.quotation.proposal.requestor.email
self.attn_to_phone = self.quotation.proposal.requestor.mobile
self.quot_reff = self.quotation.proposal.pro_no
self.quot_no = self.quotation.quo_no
self.quot_date = datetime.date.today()
And so far this form can works well… it can then be use to print the quotation based on selected quotation (Many2One field)
Currently the Quotation creation is like below:
Since the button is located in the Quotation generator UI, that actually stored Quotation ID.. is it possible to PASSED the Quotation ID of the opened Quotation to the Form class automatically when the user click the Download Quotation button? so there si no need for the user to select a Quotation at the wizard form?
My code that triggers the Wizard popup is like below (based on your previous guide)
@classmethod
def __setup__(cls):
super(RAGQuotation, cls).__setup__()
cls._buttons.update({
"print_quotation": {}
})
@classmethod
@ModelView.button_action('ltl_crm.act_crm_rag_quotation_report_menu_item')
def print_quotation(cls, obj):
pass
If this possible, it would be great.
Bromo