Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIG] account_interests: Migration to 17.0 #482

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions account_interests/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Interests Management',
'version': "16.0.1.1.0",
'version': "17.0.1.1.0",
'category': 'Accounting',
'sequence': 14,
'summary': 'Calculate interests for selected partners',
Expand All @@ -34,6 +34,6 @@
'data/ir_cron_data.xml',
'security/ir.model.access.csv',
],
'installable': False,
'installable': True,
'application': False,
}
17 changes: 5 additions & 12 deletions account_interests/models/res_company_interest.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,18 @@ def create_invoices(self, to_date, groupby='partner_id'):
('company_id', '=', self.company_id.id)], limit=1)

move_line_domain = self._get_move_line_domains(to_date)

# Check if a filter is set
if self.domain:
move_line_domain += safe_eval(self.domain)

fields = ['id', 'amount_residual', 'partner_id', 'account_id']
if groupby not in fields:
fields += [groupby]
fields = ['id:recordset', 'amount_residual:sum', 'partner_id:recordset', 'account_id:recordset']

move_line = self.env['account.move.line']
grouped_lines = move_line.read_group(
grouped_lines = move_line._read_group(
domain=move_line_domain,
fields=fields,
groupby=[groupby],
aggregates=fields,
)

self = self.with_context(
company_id=self.company_id.id,
mail_notrack=True,
Expand All @@ -167,8 +163,7 @@ def create_invoices(self, to_date, groupby='partner_id'):
total_items = len(grouped_lines)
_logger.info('%s interest invoices will be generated', total_items)
for idx, line in enumerate(grouped_lines):

debt = line['amount_residual']
debt = line[2]

if not debt or debt <= 0.0:
_logger.info("Debt is negative, skipping...")
Expand All @@ -177,12 +172,10 @@ def create_invoices(self, to_date, groupby='partner_id'):
_logger.info(
'Creating Interest Invoice (%s of %s) with values:\n%s',
idx + 1, total_items, line)
partner_id = line[groupby][0]

partner_id = line[0].id
partner = self.env['res.partner'].browse(partner_id)
move_vals = self._prepare_interest_invoice(
partner, debt, to_date, journal)

move = self.env['account.move'].create(move_vals)

if self.automatic_validation:
Expand Down
2 changes: 1 addition & 1 deletion account_interests/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_res_company_interest_all,access_res_company_interest_all,model_res_company_interest,,1,0,0,0
access_res_company_interest_all,access_res_company_interest_all,model_res_company_interest,base.group_user,1,0,0,0
access_res_company_interest_manager,access_res_company_interest_manager,model_res_company_interest,account.group_account_manager,1,1,1,1
2 changes: 1 addition & 1 deletion account_interests/views/res_company_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<separator string="Intereses Automáticos"/>
<field name="interest_ids" context="{'default_company_id': id}">
<tree>
<field name="company_id" invisible="1" required="0"/>
<field name="company_id" required="0" invisible="1"/>
<field name="receivable_account_ids" widget="many2many_tags"/>
<field name="interest_product_id"/>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
Expand Down