Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
4336 Lượt xem

I need to customize the sale order action_confirm method to skip product quantity validation step and deliver the order once I confirmed the sale order 

How to do it ? 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hii Abdullah ,

Please find code in Comment. 

Note: Make sure that you have on hand quantities of the product to be sold otherwise it will raise error message 
"You cannot validate a transfer if no quantities are reserved nor done. To force the transfer, switch in edit mode and encode the done quantities."

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Ảnh đại diện
Huỷ bỏ

You can try this below code:

in py:
class SaleOrderInherit(models.Model):
_inherit = 'sale.order'

def action_confirm(self):
res = super(SaleOrderInherit, self).action_confirm()
for sale_rec in self:
delivery = self.env['stock.picking'].search([('sale_id', '=', sale_rec.id)])
delivery.action_set_quantities_to_reservation()
delivery.button_validate()
return res

Câu trả lời hay nhất

Hello this is Gulshan Negi

Well, by creating a custom module and overriding the method, you can modify the action_confirm method of a sale order in Odoo. You can modify the procedure in the following manner to skip the product quantity validation step and immediately deliver the order:

@api.multi
def action_confirm(self):
for order in self:
# Skip product quantity validation step
order.state = 'sale'
# Deliver the order
order.action_done()
return True

I hope you are clear now.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
5
thg 9 25
22351
3
thg 8 25
3270
1
thg 5 25
3124
1
thg 4 25
4097
1
thg 4 25
4961