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
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.