Skip to Content
Menu
This question has been flagged
1 Atsakyti
138 Rodiniai

Hello everyone,


I created an automation that sends an alert to the sales representative once a manufacturing order created from their sales order is completed.


The sales rep should be responsible for the manufacturing order they initiated.


I would like to set up an automation where the sales rep who created the manufacturing order is automatically assigned as responsible, without needing to manually assign themselves each time.


Has anyone implemented something similar, or can suggest the best way to achieve this?


Thanks in advance!


Portretas
Atmesti

Hi,
You could try to make an automated action, and assign `record.sale_order_id.user_id` as Value.
Best Regards,
Dawid Gacek, Adapt IT

Best Answer

Hi,

By default, when a Manufacturing Order (MO) is generated from a Sales Order (SO), Odoo doesn’t assign a Responsible user automatically. The field user_id on mrp.production (MO) usually defaults to the Manufacturing team lead or stays empty, not the sales rep.


Try any of the following methods.

1-Server Action (Automated Action)

  • Model: Manufacturing Order (mrp.production)
  • Trigger: On Creation
  • Action: Write user_id from the related Sales Order (origin) → which points to the SO. Example code in a Python action:

    if record.origin: sale = env['sale.order'].search([('name', '=', record.origin)], limit=1) if sale and sale.user_id: record.user_id = sale.user_id.id

This ensures the Sales Rep (sale.order.user_id) becomes the MO’s responsible.

2- Studio / No-Code (if you have Odoo Studio)

  • Add a related field on MO: sales_order_user = fields.Many2one('res.users', related='sale_id.user_id')
  • Then set a default for Responsible = that related field.

3- Custom Module (Cleanest for Production)

If you want it consistent across all environments, override the create method in mrp.production:

from odoo import models, api class MrpProduction(models.Model): _inherit = "mrp.production" @api.model def create(self, vals): res = super().create(vals) if res.origin: sale = self.env['sale.order'].search([('name', '=', res.origin)], limit=1) if sale and sale.user_id: res.user_id = sale.user_id.id return res

* If you want a quick solution, go with the Automated Action — no code deployment needed.

*If this is for a multinational / production setup, implement it as a small custom module so it’s clean, version-controlled, and works regardless of Studio/Automation.


Hope it helps

Portretas
Atmesti