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

I want to create custom fields on my invoices and have them visible when printed. In Odoo 16, I could do this easily, but now it seems more complicated. Does anyone know how to do it.?

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

Hi,

Try this code:

In python file inherit account.move:


from odoo import models, fields


class AccountInvoice(models.Model):

    _inherit = 'account.move'


    custom_field = fields.Char(string='Custom Field') 


We can inherit the report_invoice_document and add the corresponding changes to the file.:

<template id="report_invoice_customized" inherit_id="account.report_invoice_document">
      <xpath expr="//t[@t-set='address']" position="after">
<span t-field="o.custom_field"/></div>
   </xpath>
</template>


Hope it helps


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

 HI  Leonides Valverde Vasquez


This way you can achieve this ,

  • First of all you have to inherit field into account.move object so create .py file  

And import this file into your _init_.py file  of models.


.py file


from odoo import fields, models,api,_

class Invoice_Account(models.Model):

    _inherit = 'account.move'

    

    custom_field_name= fields.Char(string=’demo’)


Xml file


  • Now create report template xml file for inheriting this field into report of invoice
  • Create a report template xml file and give a path to this file into your manifest file.



  • You can add your custom field at any place in the invoice report by giving xpath like above pic.
  • So here this way , you can add custom fields into the invoice report.




 I hope this is helpful to you.


 Thanks & Regards,

 Email: odoo@devintellecs.com

 Skype: devintelle

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
7
thg 8 25
26243
2
thg 7 25
2139
0
thg 3 25
1204
1
thg 7 24
2078
1
thg 5 25
3314