0
votes

I am entering data in Quotation screen and i want that when i confirm sale for this Quotation than screen should be move to Sales Order menu. Firstly i got the action id for both action(Quotation and Sales order). But i facing problem that how to pass this action id in action_confirm method? Is there any solution for this type problem?

This is my code:

@api.multi
def action_confirm(self):
    if self.partner_id.pet_names:
        for record in self.partner_id.pet_names:
        if record == self.pet_names_info:
            if self.order_line:
                for s in self.order_line:
                    if s.product_id:
                        if self.ser1 or self.ind_ser1:
                            self.confirm_rental_service()  # Rental service
                            self.confirm_rental_service_history()  # Rental history maintain
                        break
                res = super(sale_order_pet, self).action_confirm()
                if res:
                    self.confirm_email_template()
                action = self.env.ref('sale.action_orders').read()[0]
                action['res_id'] = self.ids[0]
                action['name'] = 'Sales Order'
                return action
            else:
                raise ValidationError("Please Add Products in Order Lines")

Thanks in advance

1

1 Answers

0
votes

sale.action_orders action invocation looks fine to me. Have you tried to debug your code or just try to see whether it passes through all the if/else statements required to reach the action = self.env.ref('sale.action_orders').read()[0] statement?

What does Odoo return when you try to confirm the quotation / order?

According to your code, I guess that res.partner's pet_names might be a one2many field: is sale.order's pet_names_info a record belonging to the same class of pet_names? pet_names_info suggests something like a text field, not a one2many field.

Furthermore, comparing two records in conditional statement sounds a bit weird IMHO.

PS: by the way - naive question - is the first "if" statement closed by an "else" code chunk?