Odoo Help


Add Sales Order Reference to Automatic generated Purchase Order

Michael Aigner
on 11/9/15, 6:03 AM 1,564 views

We run an ecommerce shop (Magento with the OCA Connector) and use Odoo for inventory management and purchasing. We now want Odoo to create purchase orders for all incoming sales orders where the stock is not available. I managed that by creating reordering rules for alle products and by assigning suppliers to all products. Our process is that we order once a day with our production partners, therefore Odoo automatically merges multiple purchase orders to one order. This behavior is fine, but I have now the problem that I don't know which purchase order line belongs to which sales order. How can I add the sales order reference to each purchase order line?

Michael Aigner
On 3/11/16, 9:58 AM

we finally found a solution. there is a great plugin out there that allows exactly that functionality:


No module is needed, just put inherit the _make_po_get_domain function and put the origin field in the domain.

soon it starts to create purchase orders linked to the sales order.

def _make_po_get_domain(self, partner):

gpo = self.rule_id.group_propagation_option

group = (gpo == 'fixed' and self.rule_id.group_id) or \

(gpo == 'propagate' and self.group_id) or False

# import ipdb; ipdb.set_trace()

domain = (

('partner_id', '=', partner.id),

('state', '=', 'draft'),

('origin', '=', self.origin),

('picking_type_id', '=', self.rule_id.picking_type_id.id),

('company_id', '=', self.company_id.id),

('dest_address_id', '=', self.partner_dest_id.id))

if group:

domain += (('group_id', '=', group.id),)

return domain

Douglas Barbosa
on 3/27/18, 1:49 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 11/9/15, 6:03 AM
Seen: 1564 times
Last updated: 3/11/16, 9:58 AM