Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
5661 Lượt xem

Hii,

I have a custom field added in the header of the account.invoice. I have added the same custom filed to account.invoice.line.
When I create an Invoice directly or from PO I assign a value to this field.
How to pass custom field value to from invoice header to all lines?

I have done it  overriding write() and onchage() methods but no luck on create() method. 

How to pass it by overriding create() method.

I am doing it the following way but not working...

@api.model
def create(self, values):
result = super(FFTAccountInvoice, self).create(values)
     values.update({'invoice_line_ids': [(0, 0, {'shipment_id': result['shipment_id'].id})]})
     return result



Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

The requirement can be achieved by overriding create() and write() methods, or even field onchage() method.
But I have done it by Related field as following and it is working fine with me..

class TTAccountInvoiceLine(models.Model):
_inherit = 'account.invoice.line'
    shipment_id = fields.Many2one('purchase.shipment', string='Shipment', related='invoice_id.shipment_id', store=True)

 in account.invoice i have custom filed shipment_id. So related='invoice_id.shipment_id'.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 9 24
11204
1
thg 6 23
2312
1
thg 4 23
11379
1
thg 6 22
2638
0
thg 3 22
2