I've inherited create function for account_analytic_line. The logic there is that if the field support_ticket_id is coming on vals dictionary, it will execute all the code inside the if statement.
@api.model
def create(self, vals):
for val in vals:
if 'support_ticket_id' in val:
ticket_id = vals['support_ticket_id']
ticket = self.env['website.support.ticket'].search([('id', '=', ticket_id)], limit=1)
vals['account_id'] = ticket.analytic_account_id.id
res = super(AccountAnalyticLine, self).create(vals)
return res
The weird thing is that, on my local enviroment is working fine. But on the production enviroment, is throwing this error:
TypeError: create() missing 1 required positional argument: 'vals'
More weird thing is that, if I change to @api.multi (I know that it can't be used in create method, but I just gave it a shot) and on my local enviroment is throwing same mistake, but on production is working fine. So it's all backwards between local and production and I don't know what is triggering this.
Try with code:
@api.model
def create(self, vals):
if vals.get("support_ticket_id"):
ticket_id = vals.get("support_ticket_id")
ticket = self.env['website.support.ticket'].browse(ticket_id)
if ticket.analytic_account_id:
vals['account_id'] = ticket.analytic_account_id.id
res = super(AccountAnalyticLine, self).create(vals)
return res
Few points improved: