Skip to Content
Menu
This question has been flagged

Hello,


Does anyone know how to change the sequences of delivery orders to match the associated sale order.


For example, the sequence of the delivery would be:


WH/OUT/04538/01


04538 being the SO number and 01 being the number of delivery orders associated to the SO.


Thank you very much.


Julien

Avatar
Discard

Bonjour,


Ne travaillant actuellement plus chez Deuse, je vous invite à transférer ce mail à Arthur De L'Arbre : a.delarbre@deuse.be


Bonne journée, 

Best Answer

Hi, Julien Plaitin


from odoo import models, fields, api


class StockPicking(models.Model):

    _inherit = 'stock.picking'


    sale_order_number = fields.Char(string='Sale Order Number')


    @api.model

    def create(self, vals):

        """

        Overrides the create method of stock.picking model to customize the creation of new picking records.

        """

        if vals.get('origin'):

            sale_order_number = vals['origin']

            existing_delivery_orders_count = self.search_count([('origin', '=', sale_order_number)])

            vals['name'] = f"WH/OUT/{sale_order_number}/{existing_delivery_orders_count + 1:02d}"

        return super(StockPicking, self).create(vals)


Please refer to the attached screenshot.




I Hope this information proves helpful to you. 


Thanks & Regards,

Email:   odoo@aktivsoftware.com           

Skype: kalpeshmaheshwari

Avatar
Discard
Related Posts Replies Views Activity
2
Nov 24
1161
0
Nov 18
2986
0
Nov 24
1205
0
Sep 24
1251
2
Jul 24
1041