Add field to optionally define analytic account on commission line

This commit is contained in:
mdietrichc2c
2016-10-31 13:33:53 +01:00
parent fa0b5ce376
commit f25372554b
2 changed files with 11 additions and 0 deletions

View File

@@ -71,6 +71,11 @@ class AccountJournal(models.Model):
help="Two counterparts will be automatically created : one for "
"the refunds and one for the payments")
commission_analytic_account_id = fields.Many2one(
comodel_name='account.analytic.account',
string='Commission Analytic Account',
help="Choose an analytic account to be used on the commission line.")
def _get_rules(self):
# We need to respect the sequence order
return sorted(self.rule_ids, key=attrgetter('sequence'))
@@ -196,6 +201,11 @@ class AccountJournal(models.Model):
'account_id': commission_account_id,
'already_completed': True,
}
if self.commission_analytic_account_id:
comm_values.update({
'analytic_account_id':
self.commission_analytic_account_id.id
})
move_line_obj.with_context(
check_move_validity=False
).create(comm_values)