Ir al contenido
Menú
Se marcó esta pregunta

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
Descartar

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, 

Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
nov 24
1182
0
nov 18
2989
0
nov 24
1217
0
sept 24
1273
2
jul 24
1054