From 0b2c32ed622628c2ec94557fa411be186fb3f7d2 Mon Sep 17 00:00:00 2001 From: amcor Date: Mon, 27 May 2019 17:08:53 +0200 Subject: [PATCH] [MIG] account_loan: Migration to 12.0 --- account_loan/__manifest__.py | 2 +- account_loan/model/account_loan.py | 10 ++++------ account_loan/readme/CONTRIBUTORS.rst | 3 +++ account_loan/readme/DESCRIPTION.rst | 12 ++++++++++++ account_loan/readme/USAGE.rst | 18 ++++++++++++++++++ .../wizard/account_loan_generate_entries.py | 3 +-- 6 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 account_loan/readme/CONTRIBUTORS.rst create mode 100644 account_loan/readme/DESCRIPTION.rst create mode 100644 account_loan/readme/USAGE.rst diff --git a/account_loan/__manifest__.py b/account_loan/__manifest__.py index f0fd883f7..5e152e22a 100644 --- a/account_loan/__manifest__.py +++ b/account_loan/__manifest__.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Account Loan management", - "version": "11.0.1.1.1", + "version": "12.0.1.0.0", "author": "Creu Blanca,Odoo Community Association (OCA)", "website": "http://github.com/OCA/account-financial-tools", "license": "AGPL-3", diff --git a/account_loan/model/account_loan.py b/account_loan/model/account_loan.py index df85b2a17..70f2b6b1c 100644 --- a/account_loan/model/account_loan.py +++ b/account_loan/model/account_loan.py @@ -353,7 +353,7 @@ class AccountLoan(models.Model): def post(self): self.ensure_one() if not self.start_date: - self.start_date = fields.Datetime.now() + self.start_date = fields.Date.today() self.compute_draft_lines() self.write({'state': 'posted'}) @@ -422,7 +422,7 @@ class AccountLoan(models.Model): self.line_ids.unlink() amount = self.loan_amount if self.start_date: - date = datetime.strptime(self.start_date, DF).date() + date = self.start_date else: date = datetime.today().date() delta = relativedelta(months=self.method_period) @@ -470,8 +470,7 @@ class AccountLoan(models.Model): ('is_leasing', '=', False) ]): lines = record.line_ids.filtered( - lambda r: datetime.strptime( - r.date, DF).date() <= date and not r.move_ids + lambda r: r.date <= date and not r.move_ids ) res += lines.generate_move() return res @@ -484,7 +483,6 @@ class AccountLoan(models.Model): ('is_leasing', '=', True) ]): res += record.line_ids.filtered( - lambda r: datetime.strptime( - r.date, DF).date() <= date and not r.invoice_ids + lambda r: r.date <= date and not r.invoice_ids ).generate_invoice() return res diff --git a/account_loan/readme/CONTRIBUTORS.rst b/account_loan/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..014726dc6 --- /dev/null +++ b/account_loan/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Enric Tobella +* Bhavesh Odedra +* Alberto Martín Cortada \ No newline at end of file diff --git a/account_loan/readme/DESCRIPTION.rst b/account_loan/readme/DESCRIPTION.rst new file mode 100644 index 000000000..42a7a8a9d --- /dev/null +++ b/account_loan/readme/DESCRIPTION.rst @@ -0,0 +1,12 @@ +This module extends the functionality of accounting to support loans. +It will create automatically moves or invoices for loans. +Moreover, you can check the pending amount to be paid and reduce the debt. + +It currently supports two kinds of debts: + +* Loans: a standard debt with banks, that only creates account moves. + Loan types info: + `APR `_, + `EAR `_, + `Real Rate `_. +* Leases: a debt with a bank where purchase invoices are necessary diff --git a/account_loan/readme/USAGE.rst b/account_loan/readme/USAGE.rst new file mode 100644 index 000000000..d5c3bde3f --- /dev/null +++ b/account_loan/readme/USAGE.rst @@ -0,0 +1,18 @@ +To use this module, you need to: + +#. Go to `Invoicing / Accounting > Adviser > Loans` +#. Configure a loan selecting the company, loan type, amount, rate and accounts +#. Post the loan, it will automatically create an account move with the + expected amounts +#. Create automatically the account moves / invoices related to loans and + leases before a selected date + +On a posted loan you can: + +* Create moves or invoices (according to the configuration) +* Modify rates when needed (only unposted lines will be modified) +* Reduce or cancel the debt of a loan / lease + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/92/11.0 \ No newline at end of file diff --git a/account_loan/wizard/account_loan_generate_entries.py b/account_loan/wizard/account_loan_generate_entries.py index be8f2fdf1..ce5e8bc86 100644 --- a/account_loan/wizard/account_loan_generate_entries.py +++ b/account_loan/wizard/account_loan_generate_entries.py @@ -35,8 +35,7 @@ class AccountLoanGenerateWizard(models.TransientModel): return result def run_loan(self): - created_ids = self.env['account.loan'].generate_loan_entries( - datetime.strptime(self.date, DF).date()) + created_ids = self.env['account.loan'].generate_loan_entries(self.date) action = self.env.ref('account.action_move_line_form') result = action.read()[0] if len(created_ids) == 0: