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?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
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 :)
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 3 23
|
2561 | ||
READONLY PRICE UNIT
Đã xử lý
|
|
7
thg 7 19
|
4902 | |
|
0
thg 6 19
|
3317 | ||
|
0
thg 3 19
|
5413 | ||
|
2
thg 9 18
|
3383 |