0

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

Pawan Kumar Sharma
  • 1,168
  • 8
  • 30

1 Answers1

0

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?

dbrus
  • 79
  • 1
  • 3
  • Hi dbrus, Remaining code working fine and after print action i getting right action id = '240' which is Sales Order id. Still it is not changed to Sales Order. Please find anything else missing in return action? Thanks. – Pawan Kumar Sharma Jul 21 '18 at 09:19
  • What does it happen when you confirm the order? Does it return the order's form view? Can you the access to the `action` variable dictionary just before being returned by the `action_confirm` and please paste it here? I guess you might somehow replace the `res_id` key-value with something like this: `action['domain'] = [('id', 'in', ids)]` – dbrus Jul 21 '18 at 10:58