Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
381 Vistas

I have 4 inventory locations, and each inventory has its own manager.

I want to set up an approval process for internal transfers in Odoo, so that:


When an internal transfer is created from or to a specific inventory location,


An approval request is sent automatically to that inventory's assigned manager before the transfer is validated.


How can I implement this in Odoo?

Avatar
Descartar
Mejor respuesta

The prerequisite for my below response is that you will need to have a studio within your subscription, since we will be using "Approval Rules" 

I am also assuming based on your question that you are asking specifically for internal transfers betwen internal locations and not all inventory movements between locations. 

In order to set this up, Update Destination Location in Odoo

1. Click on Toggle Studio

2. Click on Mark as Todo

3. Click on "Approvers" 

4. Add your desired "Approvers" 

5. Create a filter for yoru approval condition

6. Click on dropdown for related fields within the model

7. Type "Destination Location"

8. Click on Destination Location

9. Add Desired Destination Location for Approval

10. Click on"Desired Warehouse Location" 

11. Click on Confirm


This process will need to be repeated across all of your locations based off of the desired "destination location" and desired "approver" 

Let me know if you have any further questions!

Avatar
Descartar
Mejor respuesta

Hi,

Here give the code for requirement ,


Implementation Steps

1. Add Manager Field on Locations


Extend the stock.location model to include a manager_id field:


class StockLocation(models.Model):

    _inherit = 'stock.location'


    manager_id = fields.Many2one('res.users', string="Location Manager")

2. Add Approval Status to Stock Picking


Extend stock.picking to include an approval field and logic:


class StockPicking(models.Model):

    _inherit = 'stock.picking'


    approval_state = fields.Selection([

        ('draft', 'Waiting Approval'),

        ('approved', 'Approved'),

        ('rejected', 'Rejected')

    ], default='draft', string="Approval Status")


    def action_approve_transfer(self):

        self.ensure_one()

        self.approval_state = 'approved'


    def action_reject_transfer(self):

        self.ensure_one()

        self.approval_state = 'rejected'

3. Block Validation Without Approval


Override the button_validate() method:


@api.multi

def button_validate(self):

    for picking in self:

        if picking.picking_type_id.code == 'internal':

            source_mgr = picking.location_id.manager_id

            dest_mgr = picking.location_dest_id.manager_id

            if source_mgr or dest_mgr:

                if picking.approval_state != 'approved':

                    raise UserError("This internal transfer must be approved by the location manager(s) before validation.")

    return super(StockPicking, self).button_validate()

4. Auto-Notify Manager(s)


On internal transfer creation, send activity to manager(s) using mail.activity:


@api.model

create(vals):

    picking = super().create(vals)

    if picking.picking_type_id.code == 'internal':

        users_to_notify = []

        if picking.location_id.manager_id:

            users_to_notify.append(picking.location_id.manager_id)

        if picking.location_dest_id.manager_id:

            users_to_notify.append(picking.location_dest_id.manager_id)

        for user in set(users_to_notify):

            self.env['mail.activity'].create({

                'res_model_id': self.env['ir.model']._get_id('stock.picking'),

                'res_id': picking.id,

                'activity_type_id': self.env.ref('mail.mail_activity_data_todo').id,

                'user_id': user.id,

                'summary': 'Approval Required for Internal Transfer',

                'note': 'Please approve this internal transfer before it can be validated.',

            })

    return picking

5. Add Approve/Reject Buttons (Optional but Recommended)


Add two buttons in the stock.picking form view (inheriting):


<button name="action_approve_transfer" string="Approve" type="object"

        attrs="{'invisible': [('approval_state', '!=', 'draft')]}" class="btn-primary"/>

<button name="action_reject_transfer" string="Reject" type="object"

        attrs="{'invisible': [('approval_state', '!=', 'draft')]}" class="btn-secondary"/>


Hope it helps




Avatar
Descartar
Mejor respuesta

Solution:

  1. Use Approval Flow with Odoo Studio (Enterprise):
    • Go to Inventory > Settings and ensure Multi-step routes and Warehouse Management are enabled.
    • Create an Internal Transfer (Operation Type: Internal Transfer).
    • Use Odoo Studio to:
      • Add a new field: approval_status (e.g., Pending, Approved, Rejected).
      • Add a button: Send for Approval → Changes approval_status to Pending.
      • Restrict transfer validation (via security rules or domain) unless approval_status == Approved.
  2. Assign Inventory Manager Group:
    • Use Access Rights to restrict who can approve (approval_status → Approved).
    • Assign approval responsibility to users in the Inventory Manager group.
  3. Automated Email Notification (Optional):
    • Go to Settings > Technical > Automation > Automated Actions.
    • Trigger: On approval_status change to "Pending".
    • Action: Send email notification to Inventory Managers.

Avatar
Descartar

What's the point of this AI / LLM answer? This is not a complete or workable solution.