Skip to content

Commit

Permalink
[FIX] issue Error when creating subvention #7
Browse files Browse the repository at this point in the history
  • Loading branch information
rlizana committed Feb 17, 2020
1 parent 433bbe6 commit 5d82dbd
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion account_subvention/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
'website': 'https://www.trey.es',
'license': 'AGPL-3',
'category': 'Accounting & Finance',
'version': '12.0.1.1.0',
'version': '12.0.1.2.0',
'depends': [
'account_payment',
'account_analytic_parent',
Expand Down
2 changes: 1 addition & 1 deletion account_subvention/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_account_subvention,access_account_subvention,model_account_subvention,,1,0,0,0
access_account_subvention,access_account_subvention,model_account_subvention,account.group_account_invoice,1,1,1,1
access_account_subvention_manager,access_account_subvention,model_account_subvention,account.group_account_invoice,1,1,1,1
2 changes: 1 addition & 1 deletion account_subvention/views/account_subvention_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</group>
<group colspan="2" col="2">
<field name="journal_id"/>
<field name="account_id" domain="[('type', '!=', 'view')]"/>
<field name="account_id"/>
</group>
<group colspan="2" col="2">
<field name="amount"/>
Expand Down
23 changes: 14 additions & 9 deletions account_subvention/wizards/print_options_account_subvention.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ def get_expedients(self, subvention, trimester, target_year):
'associated invoices') % account_move_line.name)
invoice_line = account_move_line.invoice_id.invoice_line_ids[0]
expedient_id = (
invoice_line.account_analytic_id and
invoice_line.account_analytic_id.parent_id and
invoice_line.account_analytic_id.parent_id.id or -1)
invoice_line.account_analytic_id
and invoice_line.account_analytic_id.parent_id
and invoice_line.account_analytic_id.parent_id.id
or -1)
expedient_name = (
invoice_line.account_analytic_id and
invoice_line.account_analytic_id.parent_id and
invoice_line.account_analytic_id.parent_id.name or
'No expedient')
invoice_line.account_analytic_id
and invoice_line.account_analytic_id.parent_id
and invoice_line.account_analytic_id.parent_id.name
or 'No expedient')
expedients.setdefault(expedient_id, {
'name': expedient_name,
'addresses_sorted': [],
Expand Down Expand Up @@ -104,8 +105,12 @@ def get_expedients(self, subvention, trimester, target_year):
partner_id['subvs'].update({
month: account_move_line.subvention_percent})
partner_id['subv_imports'].update({
month: (amount_total *
account_move_line.subvention_percent / 100)})
month: (
amount_total
* account_move_line.subvention_percent
/ 100
)
})
expedients[expedient_id]['exp_total'] += partner_id[
'subv_imports'][month]
for key in numbers:
Expand Down
14 changes: 9 additions & 5 deletions account_subvention/wizards/wizard_change_subvention.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ def action_to_step_done(self):
self.ensure_one()
for line in self.lines:
move_subvention = line.invoice_id.move_id.line_ids.filtered(
lambda mv: mv.subvention_id and mv.subvention_percent and
mv.account_id == line.invoice_id.account_id[0])
lambda mv:
mv.subvention_id
and mv.subvention_percent
and mv.account_id == line.invoice_id.account_id[0]
)
if not move_subvention:
raise exceptions.Warning(
_('Not account move subvention for invoice: %s') %
Expand All @@ -88,8 +91,9 @@ def action_to_step_done(self):
new_subvention = float_round(
line.invoice_line_price * self.subvention_percent / 100, dp)
old_subvention = float_round(
line.invoice_line_price * line.invoice_subvention_percent /
100, dp)
line.invoice_line_price
* line.invoice_subvention_percent
/ 100, dp)
amount_correction = new_subvention - old_subvention
narration = _('''Invoice: %s Old Subvention: %s
New Subvention: %s''') % (line.invoice_number,
Expand Down Expand Up @@ -126,7 +130,7 @@ def line_get_convert(
'partner_id': self.partner_id.id,
'name': ref[0],
'move_id': move.id,
'debit': 0.00,
'debit': 0.00,
'credit': amount,
'account_id': line.invoice_id.account_id.id}
subvention_line = {
Expand Down

0 comments on commit 5d82dbd

Please sign in to comment.