Skip to content
Extraits de code Groupes Projets
Valider 8ba66ab2 rédigé par jordan's avatar jordan
Parcourir les fichiers

[update] refactor payment_term to be used by ur_aura

parent 2a825db4
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
from datetime import datetime from datetime import datetime
import json import json
from odoo import models, fields, api, _ from odoo import models, fields, api
from odoo.exceptions import UserError
class ScopAccountInvoice(models.Model): class ScopAccountInvoice(models.Model):
...@@ -76,122 +75,17 @@ class ScopAccountInvoice(models.Model): ...@@ -76,122 +75,17 @@ class ScopAccountInvoice(models.Model):
# ------------------------------------------------------ # ------------------------------------------------------
# Override Parent # 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 # @api.multi
# def action_move_create(self): # def action_invoice_open(self):
# """ # """
# Complete override parent # Création d'une ligne dans scop.contribution
# Pass invoice in payment_term.compute function to generate payment # quand une facture cotisation devient valide
# schedule
# :return: True
# """ # """
# account_move = self.env['account.move'] # results = super(ScopAccountInvoice, self).action_invoice_open()
# # # for inv in self:
# for inv in self: # # if inv.is_contribution:
# if not inv.journal_id.sequence_id: # # inv.set_scop_contribution()
# raise UserError(_('Please define sequence on the journal related to this invoice.')) # return results
# 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
@api.one @api.one
def _get_outstanding_info_JSON(self): def _get_outstanding_info_JSON(self):
......
# Copyright 2020 Le Filament # Copyright 2020 Le Filament
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). # 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): class AccountPaymentTerm(models.Model):
_inherit = 'account.payment.term' _inherit = 'account.payment.term'
is_contribution = fields.Boolean('Conditions de paiement des cotisations') is_contribution = fields.Boolean('Conditions de paiement des cotisations')
\ No newline at end of file
# 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)
# © 2020 Le Filament (<http://www.le-filament.com>) # © 2020 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # 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): class CotisationsConfigSettings(models.TransientModel):
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter