Skip to content

Commit

Permalink
Update for compatibility after migration from Openupgrade.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fekete Mihai committed Apr 25, 2018
1 parent e863309 commit 3771eb2
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions l10n_ro_account_period_close/models/account_period_close.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,29 @@ def _onchange_type(self):
if self.type == 'income':
acc_type = self.env.ref(
'account.data_account_type_revenue').id
if acc_type:
accounts = self.env['account.account'].search([
('user_type_id', '=', acc_type),
('company_id', '=', self.company_id.id)
])
if not accounts:
accounts = self.env['account.account'].search([
('user_type_id.name', '=', 'Income'),
('company_id', '=', self.company_id.id)
])
elif self.type == 'expense':
acc_type = self.env.ref(
'account.data_account_type_expenses').id
if acc_type:
accounts = self.env['account.account'].search([
('user_type_id', '=', acc_type),
('company_id', '=', self.company_id.id)
])
if acc_type:
accounts = self.env['account.account'].search([
('user_type_id', '=', acc_type),
('company_id', '=', self.company_id.id)
])
if not accounts:
accounts = self.env['account.account'].search([
('user_type_id.name', '=', 'Expense'),
('company_id', '=', self.company_id.id)
])
self.account_ids = accounts

def _get_accounts(self, accounts, display_account):
Expand Down Expand Up @@ -124,10 +139,12 @@ def close(self, date_from=None, date_to=None):
journal_id = self.journal_id.id
for closing in self:
ctx = self.env.context.copy()
ctx['strict_range'] = True
ctx['state'] = 'posted'
ctx['date_from'] = date_from
ctx['date_to'] = date_to
ctx.update({
'strict_range': True,
'state': 'posted',
'date_from': date_from,
'date_to': date_to
})
account_res = self.with_context(ctx)._get_accounts(
closing.account_ids, 'not_zero')
move = self.env['account.move'].create({
Expand Down

0 comments on commit 3771eb2

Please sign in to comment.