Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
3191 Tampilan

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
Buang

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.

Penulis

Thank you, its fine now!

Jawaban Terbai

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
Buang
Penulis

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!

Post Terkait Replies Tampilan Aktivitas
1
Agu 24
5844
0
Mar 15
3470
2
Des 19
3744
1
Jul 16
8095
1
Jan 20
2781