Skip to Content
Menu
This question has been flagged
1 Reply
2698 Views

Hi, im creating simple script which from invoices download a .txt document with needed information.

whenever i want to get res.partner company name i get a string value "false".  How can i get the full company name and not the value "False"

code:

def invoice_export(self):
context = dict(self._context or {})
active_ids = context.get('active_ids', []) or []  
with open('Invoice.txt', 'w', encoding='utf-8') as file:
file.write(" SoftwareCompanyName: SoftwareName: SoftwareVersion: RegistrationNumber:")
for label in self.env['account.invoice'].browse(active_ids):
for line in label.invoice_line_ids:
file.write("\n{} {} {} {}".format(str(line.create_date), label.partner_id.company_name, "Odoo", "11.0")) #getting value right here

Avatar
Discard

You need to check whether your partner has company_nale filled or not. If not filled then it will return False.

Author

@ibrahim, yes. thank you ! already found. it is Just label.partner_id.name not company name...

Author

@ibrahim, yes. thank you ! already found. it is Just label.partner_id.name not company name...

Best Answer

hey try this

def invoice_export(self):
    print(self.env.user.company_id.display_name)
    ....
    ....    
    ....
Avatar
Discard
Related Posts Replies Views Activity
2
Jul 24
941
1
Jun 24
3563
1
Oct 23
8590
1
Oct 23
97
1
Aug 23
2192