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:
- 客户关系管理
- e-Commerce
- 会计
- 库存
- PoS
- Project
- MRP
此问题已终结
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!
相关帖文 | 回复 | 查看 | 活动 | |
---|---|---|---|---|
|
1
8月 24
|
5896 | ||
|
0
3月 15
|
3520 | ||
|
2
12月 19
|
3786 | ||
|
1
7月 16
|
8168 | ||
|
1
1月 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!