跳至内容
菜单
此问题已终结
2 回复
3175 查看


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)

形象
丢弃
编写者
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.

编写者 最佳答案

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


形象
丢弃

ِThis is work and my below answer also work.

最佳答案


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)
形象
丢弃
相关帖文 回复 查看 活动
1
11月 21
2348
1
7月 25
2285
2
7月 25
7757
2
7月 25
4176
2
7月 25
3956