Skip to content

Commit

Permalink
Merge 9c074a6 into cf6d475
Browse files Browse the repository at this point in the history
  • Loading branch information
vrenaville committed Oct 30, 2019
2 parents cf6d475 + 9c074a6 commit 8fc3684
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions account_cutoff_base/models/account_cutoff.py
Expand Up @@ -54,6 +54,13 @@ def _default_cutoff_journal_id(self):
states={'draft': [('readonly', False)]}, copy=False,
track_visibility='onchange'
)

partner_split = fields.Boolean(
string='Split by Partner', readonly=True,
states={'draft': [('readonly', False)]}, copy=False,
track_visibility='onchange'
)

cutoff_type = fields.Selection(
selection='_selection_cutoff_type',
string='Type',
Expand Down Expand Up @@ -152,7 +159,10 @@ def _get_merge_keys(self):
same values for these fields will be merged.
The list must at least contain account_id.
"""
return ['account_id', 'analytic_account_id']
merge_keys = ['account_id', 'analytic_account_id']
if self.partner_split:
merge_keys.append('partner_id')
return merge_keys

@api.multi
def _prepare_move(self, to_provision):
Expand Down Expand Up @@ -200,11 +210,14 @@ def _prepare_provision_line(self, cutoff_line):
If you override this, the added fields must also be
added in an override of _get_merge_keys.
"""
return {
provision_line = {
'account_id': cutoff_line.cutoff_account_id.id,
'analytic_account_id': cutoff_line.analytic_account_id.id,
'amount': cutoff_line.cutoff_amount,
}
if self.partner_split:
provision_line.update({'partner_id': cutoff_line.partner_id.id})
return provision_line

@api.multi
def _prepare_provision_tax_line(self, cutoff_tax_line):
Expand Down
1 change: 1 addition & 0 deletions account_cutoff_base/views/account_cutoff.xml
Expand Up @@ -32,6 +32,7 @@
<group name="top">
<group name="general-params">
<field name="cutoff_date"/>
<field name="partner_split"/>
<field name="total_cutoff_amount"/>
<field name="company_id" groups="base.group_multi_company" widget="selection" />
<field name="company_currency_id" invisible="1"/>
Expand Down

0 comments on commit 8fc3684

Please sign in to comment.