Skip to Content
Menu
This question has been flagged
2 Replies
1871 Views


class SaleTransportOrder(models.Model):

          _inherit = 'sale.order'

          transport_id = fields.Many2one('transport.management', string="Transport Via", required=True)
          def  action_confirm(self):

          rec = super(SaleTransportOrder, self).action_confirm()

           i = self.env['stock.picking'].create({'transport_id':self.transport_id.id, })

           returnrec

class   Stockpicking(models.Model):

            _inherit = "stock.picking"
            transport_id = fields.Many2one("transport.management",string="Transport Via",tracking=True,required=True ,           readonly=True)

Avatar
Discard
Author
bro not showing any thing please type enlish

On Thu, Dec 29, 2022 at 6:12 PM Malik Imad Khan <notifications@mail.odoo.com> wrote:

Une nouvelle question how to pass value sale.order to stock.picking , below my code i am trying but not work please help me, i use odoo V14 le Aide a été publiée. Cliquez ici pour accéder à la question :

Voir la question

--
Malik Imad Khan

Envoyé par Odoo S.A. utilisant Odoo.

Author Best Answer

i was value create or write sale.order to stock.picking but now done

this code.

def action_confirm(self):

    res = super(SaleTransportOrder,self).action_confirm()

    for rec in self:

   rec.picking_ids.write({'transport_id':rec.transport_id.id})

   return res

this is answer


Avatar
Discard

ِThis is work and my below answer also work.

Best Answer


sale_id field already exists in stock.picking so you need to add "sale_stock" to your depends in __manifest__.py file and then you can add related field as below to get  transport_id  in stock.picking.

You don't need to override  action_confirm  in sale order. so you can remove it. 

class SaleTransportOrder(models.Model):
_inherit = 'sale.order'

transport_id = fields.Many2one('transport.management', string="Transport Via", required=True)

class Stockpicking(models.Model):
_inherit = "stock.picking"

transport_id = fields.Many2one(related="sale_id.transport_id ", string="Transport Via", store=True)
Avatar
Discard
Related Posts Replies Views Activity
1
Nov 21
1757
1
Nov 24
1483
1
Nov 24
1188
2
Sep 24
1047
1
Aug 24
2451