Skip to content

Commit

Permalink
Merge pull request #200 from dcorio/11.0-FIX-sale_commission-invoice_id
Browse files Browse the repository at this point in the history
[11.0][FIX] avoid KeyError
  • Loading branch information
pedrobaeza committed Feb 5, 2019
2 parents 3f7045e + 9aa44b9 commit 2451f19
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sale_commission/models/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ def create(self, vals):
"""Add agents for records created from automations instead of UI."""
# We use this form as this is the way it's returned when no real vals
agents_vals = vals.get('agents', [(6, 0, [])])
if agents_vals and agents_vals[0][0] == 6 and not agents_vals[0][2]:
inv = self.env['account.invoice'].browse(vals['invoice_id'])
invoice_id = vals.get('invoice_id', False)
if (agents_vals and agents_vals[0][0] == 6 and not
agents_vals[0][2] and invoice_id):
inv = self.env['account.invoice'].browse(invoice_id)
vals['agents'] = self._prepare_agents_vals_partner(inv.partner_id)
return super().create(vals)

Expand Down

0 comments on commit 2451f19

Please sign in to comment.