Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
2288 Zobrazení

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
Zrušit

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, 

Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
lis 24
1294
0
lis 18
3043
0
lis 24
1326
0
zář 24
1381
2
čvc 24
1138