Hello Dear,
In the project task I created a new page with order lines.
The problem is I want to pass my lines to the sales order lines quotation. nothing shown in the quotation.
all other default values are passed.
Here is my code:
class ProjectTaskInherit(models.Model):
_inherit = 'project.task'
project_task_product_ids = fields.One2many('project.task.product', 'project_task_id', string='Product Lines')
def new_quotation(self):
project_task_product_ids = [(5, 0, 0)]
for res in self.project_task_product_ids:
line = [(0, 0, {
'product_id': res.product_id.id,
'product_uom_qty': res.qty
})]
project_task_product_ids.append(line)
# print(project_task_product_ids)
context = {
'fsm_mode': True,
'form_view_initial_mode': 'edit',
'default_partner_id': self.partner_id.id,
'default_task_id': self.id,
'default_company_id': self.company_id.id,
'default_origin': _('%s - %s') % (self.project_id.name, self.name),
'default_order_line': project_task_product_ids
}
action = {
'name': 'My Existing View', # Set the name of the view
'type': 'ir.actions.act_window', # Set the type of action
'res_model': 'sale.order', # Set the model of the view to be opened
'view_mode': 'form', # Set the view mode
'view_type': 'form', # Set the view type
'view_id': self.env.ref("sale.view_order_form").id,
'target': 'self', # Set the target to open the view in the same window
'context': context
}
# Return the action dictionary
return action
I think the problem is in the order line dictionary key in context.
Thanks in advanced