Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
2180 Lượt xem
I recently added a custom Char field called 'Report No' to the invoice lines in Odoo 15, 
using the following code:

class AccountMoveLineInherited(models.Model):
_inherit = 'account.move.line'
report_no = fields.Char('Report No', required=True)


However, when I enter a new invoice line record and save it, the custom field often gets lost.
I'm not sure why this is happening and would appreciate any suggestions or solutions. Thank you.

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

After encountering an issue where my custom Char field 'report_no' was getting lost when I saved new invoice line records in Odoo 15, I spent two hours troubleshooting the issue. Eventually, I discovered that the issue arose because the 'account.move' model contains two fields with the same relation to 'account.move.line', causing a conflict with my custom field. so I added the 'report_no' field in both one2many relation fields in the views 










Regards


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

Hi,

Try with the field attribute “ store”. 

Eg: 

class AccountMoveLineInherited(models.Model):
_inherit = 'account.move.line'
report_no = fields.Char('Report No', required=True, store= True)

If this is not works, try with the force_save = 1 in XML 

<field name=”report_no” force_save=”1”/>


Regards

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 23
3542
2
thg 12 24
6078
2
thg 6 24
11278
0
thg 5 23
1475
1
thg 9 22
3055