This question has been flagged

I'm trying to add a field to the pivot table "account.invoice.report".


Here's my code:

category = fields.Char(string='Category',compute='_compute_category', store=True, readonly=True)

@api.multi
@api.depends('partner_id')
def _compute_category(self):
      my_code


I can see the new field on Invoices Analysis view but when I click on it I got an error saying that the field does not exist. When I look in the database, the field does not exist.

I tried to add it also in "account.invoice" but still the field is not added in the database.

Avatar
Discard
Best Answer
hello, 
you can follow this example:
class AccountInvoiceReport(models.Model):
_inherit =
'account.invoice.report'

team_id = fields.Many2one('crm.team', string='Sales Team')

def _select(self):
return super(AccountInvoiceReport, self)._select() + ", sub.team_id as team_id"

def _sub_select(self):
return super(AccountInvoiceReport, self)._sub_select() + ", ai.team_id as team_id"

def _group_by(self):
return super(AccountInvoiceReport, self)._group_by() + ", ai.team_id"
Avatar
Discard
Best Answer

Hello Wided,

In order to add a field to account.invoice.report you have to add your field as you already did and you also have to inherit the methods _sub_select and _group_by and modify with your fields in those methods.


I hope this helps

Avatar
Discard