Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
2 Besvarelser
3249 Visninger


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
Kassér
Forfatter
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.

Forfatter Bedste svar

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
Kassér

ِThis is work and my below answer also work.

Bedste svar


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
Kassér
Related Posts Besvarelser Visninger Aktivitet
1
nov. 21
2418
1
jul. 25
2404
2
jul. 25
7890
2
jul. 25
4298
2
jul. 25
4034