Skip to Content
Menu
This question has been flagged
1204 Rodiniai

So i have added a piece of code that creates a sales quotation when a stock.picking(Transfer) is confirmed.

The problem is that two such sales quotation is created , 1 has all the fields correcty filled in but the other unwanted one has move.lines with the products but the quantity is set to 0 for each line. 

 WHat is causing this issue here, i cant seem to find out.

----------------------------------------------------------------------------------------

class PickingToQuotation (models.Model):

 _inherit = 'stock.picking


def button_validate(self):

​ res=super(PickingToQuotation,self).button_validate()

​self.action_create_quotation()

​return res


def action_create_quotation(self):

​if self.picking_type_id.code in ['outgoing','internal']:

  ​vals={'partner_id':self.partner_id.id,

​'warehouse_id':self.location_id.warehouse_id.id,

​'origin':self.name,'picking_ids':[self.id] }
​res=self.env['sale.order'].create(vals)

return True

Portretas
Atmesti
Autorius

I have dwelled into this problem and found that, when I directly validate the transfer without setting the done quantities manually, two orders are created. But when I manually set the done quantities on the transfer and then only click the validate button, only the one required sales quotation gets created.

Related Posts Replies Rodiniai Veikla
0
rugs. 25
500
0
bal. 25
2931
0
liep. 24
2104
0
bal. 24
2385
0
geg. 22
2535