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
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Contabilidad
- Inventario
- PoS
- Project
- MRP
Se marcó esta pregunta
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
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!
¿Le interesa esta conversación? ¡Participe en ella!
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
RegistrarsePublicaciones relacionadas | Respuestas | Vistas | Actividad | |
---|---|---|---|---|
|
1
ago 24
|
5826 | ||
|
0
mar 15
|
3458 | ||
How can i change product_id view
Resuelto
|
|
2
dic 19
|
3716 | |
|
1
jul 16
|
8062 | ||
|
1
ene 20
|
2781 |
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.
Thank you, its fine now!