Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
3180 Zobrazení

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
Zrušit

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!

Nejlepší odpověď

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
Zrušit
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!

Related Posts Odpovědi Zobrazení Aktivita
1
srp 24
5838
0
bře 15
3463
2
pro 19
3737
1
čvc 16
8077
1
led 20
2781