Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
3166 Vistas

I have created a code that creates a new RFQ each time I confirm the sales order. The problem is whenever I confirm the RFQ to a Purchase Order, a new rfq is created by Odoo bot, this is the code I implemented:

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

def action_confirm(self):
res = super(SaleOrderInherit, self).action_confirm()

for order in self:
partner = self.env['res.partner'].search([('commercial_partner_id', '=', '[Partner X')],
limit=1)
rfq_type = self.env['purchase.order.type'].search([('name', '=', 'RFQ')], limit=1)
purchase = self.env['purchase.order'].with_context(company_id=order.company_id.id).create({
'partner_id': partner.id,
'type_id': rfq_type.id,
'company_id': 6,
})

for line in order.order_line:
if line.product_id:
purchase.order_line |= self.env['purchase.order.line'].new({
'product_id': line.product_id.id,
'name': line.product_id.name,
'product_qty': line.product_uom_qty,
'product_uom': line.product_uom.id,
'price_unit': line.product_id.purchase_price,
'taxes_id': line.product_id.taxes,
})

return res

Avatar
Descartar

I don't think you have to do any customization to create an RFQ automatically when you confirm a sales order. Odoo has this feature in default. On the Product master, under the Inventory tab, make sure the Buy and MTO is True and under the Purchase tab, at least one vendor is added. Then when you confirm any Sales Order with this product, Odoo will automatically create an RFQ.

Autor

Thank you, its fine now!

Mejor respuesta

Hi,

Do you really need this to be customized as we have make to order available in odoo to generate a PO from sale order. Have you checked this functionality ? If not see: https://www.odoo.com/forum/help-1/how-to-automatically-create-a-purchase-order-per-sales-order-203946

Thanks

Avatar
Descartar
Autor

Yes, this works fine and I was aware of it, but due to the system customizations I faced some problems so I decided to do a customized code. But, now I tried this option and I think it's fine, thanks for your help!

Publicaciones relacionadas Respuestas Vistas Actividad
1
ago 24
5830
0
mar 15
3458
2
dic 19
3716
1
jul 16
8062
1
ene 20
2781