mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
Add field to optionally define analytic account on commission line
This commit is contained in:
@@ -71,6 +71,11 @@ class AccountJournal(models.Model):
|
|||||||
help="Two counterparts will be automatically created : one for "
|
help="Two counterparts will be automatically created : one for "
|
||||||
"the refunds and one for the payments")
|
"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):
|
def _get_rules(self):
|
||||||
# We need to respect the sequence order
|
# We need to respect the sequence order
|
||||||
return sorted(self.rule_ids, key=attrgetter('sequence'))
|
return sorted(self.rule_ids, key=attrgetter('sequence'))
|
||||||
@@ -196,6 +201,11 @@ class AccountJournal(models.Model):
|
|||||||
'account_id': commission_account_id,
|
'account_id': commission_account_id,
|
||||||
'already_completed': True,
|
'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(
|
move_line_obj.with_context(
|
||||||
check_move_validity=False
|
check_move_validity=False
|
||||||
).create(comm_values)
|
).create(comm_values)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="commission_account_id"/>
|
<field name="commission_account_id"/>
|
||||||
|
<field name="commission_analytic_account_id"/>
|
||||||
<field name="receivable_account_id" attrs="{'required': [('used_for_import', '=', True)]}"/>
|
<field name="receivable_account_id" attrs="{'required': [('used_for_import', '=', True)]}"/>
|
||||||
<field name="partner_id"/>
|
<field name="partner_id"/>
|
||||||
<field name="create_counterpart"/>
|
<field name="create_counterpart"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user