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

I would like to be able to retrieve the terms and conditions (invoice_terms) who are in the settings in order to put them in the "narration" field of an invoice that I automatically generate in my new module.

My problem comes from my access to the invoice_terms field with the model creating my invoice. I cannot find the syntax allowing this.


I tested with :

Rib_recup = fields.Char(related='account.move.narration')


But also with the self.env[].


But i don't find any solution, it would crash or only add None.None in the narration field.


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

Hi,
You can define the field as a text field and use a default or onchange function based upon your model to assign the value.
The invoice terms is defined on the res.company model , so it is fetched from 'company_id' field if the company_id field is present in the model or from 'self.env.company'.

narration = fields.Text(string='Terms and Conditions')
@api.onchange('field_a')
def _onchange_field_a(self):
if self.env['ir.config_parameter'].sudo().get_param('account.use_invoice_terms'):
self.narration = self.company_id.invoice_terms or self.env.company.invoice_terms

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 24
1871
3
thg 10 23
8123
0
thg 3 22
3453
1
thg 9 21
3309
1
thg 6 25
2382