Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda

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
Buang

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, 

Jawaban Terbai

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
Buang
Post Terkait Replies Tampilan Aktivitas
2
Nov 24
1305
0
Nov 18
3052
0
Nov 24
1351
0
Sep 24
1385
2
Jul 24
1141