diff --git a/models/account_invoice.py b/models/account_invoice.py index 67cb8c8d57c2fb9468ae617391853f7dd645d622..c7a13a6872cb2c04aae94ff34535b10f7ce0ddd4 100755 --- a/models/account_invoice.py +++ b/models/account_invoice.py @@ -4,8 +4,7 @@ from datetime import datetime import json -from odoo import models, fields, api, _ -from odoo.exceptions import UserError +from odoo import models, fields, api class ScopAccountInvoice(models.Model): @@ -76,122 +75,17 @@ class ScopAccountInvoice(models.Model): # ------------------------------------------------------ # Override Parent # ------------------------------------------------------ - @api.multi - def action_invoice_open(self): - """ - Création d'une ligne dans scop.contribution - quand une facture cotisation devient valide - """ - results = super(ScopAccountInvoice, self).action_invoice_open() - # for inv in self: - # if inv.is_contribution: - # inv.set_scop_contribution() - return results - # @api.multi - # def action_move_create(self): + # def action_invoice_open(self): # """ - # Complete override parent - # Pass invoice in payment_term.compute function to generate payment - # schedule - # :return: True + # Création d'une ligne dans scop.contribution + # quand une facture cotisation devient valide # """ - # account_move = self.env['account.move'] - # - # for inv in self: - # if not inv.journal_id.sequence_id: - # raise UserError(_('Please define sequence on the journal related to this invoice.')) - # if not inv.invoice_line_ids.filtered(lambda line: line.account_id): - # raise UserError(_('Please add at least one invoice line.')) - # if inv.move_id: - # continue - # - # if not inv.date_invoice: - # inv.write({'date_invoice': fields.Date.context_today(self)}) - # if not inv.date_due: - # inv.write({'date_due': inv.date_invoice}) - # company_currency = inv.company_id.currency_id - # - # # create move lines - # # (one per invoice line + eventual taxes and analytic lines) - # iml = inv.invoice_line_move_line_get() - # iml += inv.tax_line_move_line_get() - # - # diff_currency = inv.currency_id != company_currency - # # create one move line for the total and possibly adjust - # # the other lines amount - # total, total_currency, iml = inv.compute_invoice_totals( - # company_currency, iml) - # - # name = inv.name or '' - # if inv.payment_term_id: - # totlines = inv.payment_term_id.with_context( - # currency_id=company_currency.id).compute(total, inv.date_invoice, inv)[0] - # res_amount_currency = total_currency - # for i, t in enumerate(totlines): - # if inv.currency_id != company_currency: - # amount_currency = company_currency._convert( - # t[1], - # inv.currency_id, - # inv.company_id, - # inv._get_currency_rate_date() or fields.Date.today()) - # else: - # amount_currency = False - # - # # last line: add the diff - # res_amount_currency -= amount_currency or 0 - # if i + 1 == len(totlines): - # amount_currency += res_amount_currency - # - # iml.append({ - # 'type': 'dest', - # 'name': name, - # 'price': t[1], - # 'account_id': inv.account_id.id, - # 'date_maturity': t[0], - # 'amount_currency': diff_currency and amount_currency, - # 'currency_id': diff_currency and inv.currency_id.id, - # 'invoice_id': inv.id - # }) - # else: - # iml.append({ - # 'type': 'dest', - # 'name': name, - # 'price': total, - # 'account_id': inv.account_id.id, - # 'date_maturity': inv.date_due, - # 'amount_currency': diff_currency and total_currency, - # 'currency_id': diff_currency and inv.currency_id.id, - # 'invoice_id': inv.id - # }) - # part = self.env['res.partner']._find_accounting_partner( - # inv.partner_id) - # line = [(0, 0, self.line_get_convert(l, part.id)) for l in iml] - # line = inv.group_lines(iml, line) - # - # line = inv.finalize_invoice_move_lines(line) - # - # date = inv.date or inv.date_invoice - # move_vals = { - # 'ref': inv.reference, - # 'line_ids': line, - # 'journal_id': inv.journal_id.id, - # 'date': date, - # 'narration': inv.comment, - # } - # move = account_move.create(move_vals) - # # Pass invoice in method post: used if you want to get the same - # # account move reference when creating the same invoice - # # after a cancelled one: - # move.post(invoice = inv) - # # make the invoice point to that move - # vals = { - # 'move_id': move.id, - # 'date': date, - # 'move_name': move.name, - # } - # inv.write(vals) - # return True + # results = super(ScopAccountInvoice, self).action_invoice_open() + # # for inv in self: + # # if inv.is_contribution: + # # inv.set_scop_contribution() + # return results @api.one def _get_outstanding_info_JSON(self): diff --git a/models/account_payment_term.py b/models/account_payment_term.py index 8622951750d597eab319f41d7631d8960d7f0901..f0cc0f550551feac54aa82aca435ca56b354ae59 100644 --- a/models/account_payment_term.py +++ b/models/account_payment_term.py @@ -1,53 +1,10 @@ # Copyright 2020 Le Filament # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import fields, models, api +from odoo import fields, models class AccountPaymentTerm(models.Model): _inherit = 'account.payment.term' - is_contribution = fields.Boolean('Conditions de paiement des cotisations') - - # def compute(self, value, date_ref=False, invoice=False): - # """ - # Override la fonction compute du modèle account.payment.term - # La fonction initiale checke les conditions de paiement et crée - # les lignes de paiement associées - # - # L'héritage permet de créer un échéancier en fonction de celui - # défini sur la base de cotisations - # """ - # date_ref = date_ref or fields.Date.today() - # amount = value - # sign = value < 0 and -1 or 1 - # if self.env.context.get('currency_id'): - # currency = self.env['res.currency'].browse( - # self.env.context['currency_id']) - # else: - # currency = self.env.user.company_id.currency_id - # - # # si base de cotisation - # if self.is_contribution and invoice and (invoice.cotisation_cg_id or invoice.cotisation_aura_id): - # result = [] - # if invoice.cotisation_cg_id: - # base_contrib_field = 'cotisation_cg_id' - # elif invoice.cotisation_aura_id: - # base_contrib_field = 'cotisation_aura_id' - # trimesters = { - # 4: invoice[base_contrib_field].trimester_1, - # 3: invoice[base_contrib_field].trimester_2, - # 2: invoice[base_contrib_field].trimester_3, - # 1: invoice[base_contrib_field].trimester_4, - # } - # for i in range(invoice.nb_quarter, 0, -1): - # # Gestion de l'arrondi de la division - # if i == 1: - # amt = currency.round(amount) - # else: - # amt = currency.round(value / invoice.nb_quarter) - # result.append((fields.Date.to_string(trimesters.get(i)), amt)) - # amount -= amt - # return [result] - # else: - # return super(AccountPaymentTerm, self).compute(value, date_ref) + is_contribution = fields.Boolean('Conditions de paiement des cotisations') \ No newline at end of file diff --git a/models/res_config_settings.py b/models/res_config_settings.py index 714396c9f305f40bc63cea3d1a355e7b04d36ce1..c4835c285115b75d245988583a52deae58676fec 100644 --- a/models/res_config_settings.py +++ b/models/res_config_settings.py @@ -1,7 +1,7 @@ # © 2020 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import fields, models, api +from odoo import fields, models class CotisationsConfigSettings(models.TransientModel):