跳至內容
選單
此問題已被標幟
3 回覆
13032 瀏覽次數

I added a field in the sale.order called 'sale_notes'. And another in the stock.picking named 'delivery_notes'. I want to transfer the data from the sale_notes to the delivery_notes, when the confirm button (action_confirm) is pressed. How to accomplish that?

頭像
捨棄
最佳答案

class SaleOrder(models.Model):

    _inherit = 'sale.order'

    @api.multi

    def action_confirm(self):

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

        for do_pick in self.picking_ids:

            do_pick.write({'notes': self.note})

        return res


頭像
捨棄
最佳答案

Override the action_confirm.


@api.multi
def action_confirm(self):
res = super(sale_order, self).action_confirm()
for rec in self:
rec.picking_ids.write({'delivery_note': rec.sale_note})
return res
頭像
捨棄
最佳答案

Dear Jones,

This code will help you. 

Sale Order

-------------------------------------

from odoo import fields, models

class SaleOrder(models.Model):

    _inherit = "sale.order"

    shipping_note = fields.Text(

        string="Shipping Notes"

    )

---------------------------------------------

Picking

----------------

from odoo import api, fields, models

class Picking(models.Model):

    _inherit = "stock.picking"

    delivery_shipping_note = fields.Text(

        string="Shipping Notes",

        compute="compute_shipping_note",

    )

    @api.depends('move_lines', 'state')

    def compute_shipping_note(self):

        for record in self:

            for move in record.move_lines:

                if move.sale_line_id \

                        and move.sale_line_id.order_id.\

                        shipping_note:

                    record["delivery_shipping_note"] = \

                        move.sale_line_id.order_id.shipping_note

                    break

頭像
捨棄

This was very helpful, thanks :)

相關帖文 回覆 瀏覽次數 活動
1
3月 23
2550
7
7月 19
4895
0
6月 19
3315
0
3月 19
5406
2
9月 18
3377