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

[add] refund on bordereau

parent cdb8a4a2
Aucune branche associée trouvée
Aucune étiquette associée trouvée
2 requêtes de fusion!212.0 dev,!112.0 refactor cotiz
...@@ -13,27 +13,34 @@ ...@@ -13,27 +13,34 @@
"cgscop_cotisation", "cgscop_cotisation",
], ],
"data": [ "data": [
# Security
"security/security_rules.xml", "security/security_rules.xml",
"security/ir.model.access.csv", "security/ir.model.access.csv",
# Datas
"datas/cron.xml", "datas/cron.xml",
"datas/mail_data.xml", "datas/mail_data.xml",
"datas/mail_reminder_data.xml", "datas/mail_reminder_data.xml",
"datas/ir_sequence_data.xml", "datas/ir_sequence_data.xml",
"wizard/scop_cotisation_cg_regul_wizard.xml", # Reports
"report/report_scop_bordereau.xml", "report/report_scop_bordereau.xml",
"report/report_scop_bordereau_payments.xml", "report/report_scop_bordereau_payments.xml",
"report/report_scop_bordereau_refund.xml", "report/report_scop_bordereau_refund.xml",
# Views
"views/account_invoice.xml", "views/account_invoice.xml",
"views/res_config_settings.xml", "views/res_config_settings.xml",
"views/scop_bordereau_cg.xml",
"views/scop_cotisation_cg.xml", "views/scop_cotisation_cg.xml",
"views/scop_cotisation_simulation.xml", "views/scop_cotisation_simulation.xml",
"views/scop_liasse_fiscale.xml", "views/scop_liasse_fiscale.xml",
# Wizards
"wizard/export_journal_wizard_view.xml", "wizard/export_journal_wizard_view.xml",
"wizard/scop_bordereau_change_liasse_wizard.xml", "wizard/scop_cotisation_cg_regul_wizard.xml",
"wizard/scop_bordereau_change_payment_mode_wizard.xml", "wizard/scop_bordereau_update_liasse_wizard.xml",
"wizard/scop_bordereau_payment_mode_wizard.xml",
"wizard/scop_bordereau_refund_wizard.xml",
"wizard/scop_cotisation_cg_wizard.xml", "wizard/scop_cotisation_cg_wizard.xml",
"wizard/scop_bordereau_update_confirm_view.xml", "wizard/scop_bordereau_update_confirm_view.xml",
"wizard/scop_bordereau_validate_confirm_view.xml", "wizard/scop_bordereau_validate_confirm_view.xml",
# Wizard dependency view
"views/scop_bordereau_cg.xml",
] ]
} }
...@@ -24,6 +24,11 @@ ...@@ -24,6 +24,11 @@
string="Effectuer une Régularisation" string="Effectuer une Régularisation"
type="action" type="action"
states="validated,paid"/> states="validated,paid"/>
<button name="%(cgscop_cotisation_cg.scop_bordereau_refund_wizard_act_window)d"
class="btn-warning"
string="Ajouter un avoir"
type="action"
states="validated,paid"/>
<button name="%(cgscop_bordereau_report_refund)d" <button name="%(cgscop_bordereau_report_refund)d"
class="btn-info" class="btn-info"
string="Imprimer l'avoir" string="Imprimer l'avoir"
......
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
from . import account_invoice_refund from . import account_invoice_refund
from . import export_journal_wizard from . import export_journal_wizard
from . import scop_bordereau_change_liasse_wizard from . import scop_bordereau_update_liasse_wizard
from . import scop_bordereau_change_payment_mode_wizard from . import scop_bordereau_payment_mode_wizard
from . import scop_bordereau_refund_wizard
from . import scop_bordereau_update_confirm from . import scop_bordereau_update_confirm
from . import scop_bordereau_validate_confirm from . import scop_bordereau_validate_confirm
from . import scop_cotisation_cg_regul from . import scop_cotisation_cg_regul
......
# Copyright 2021 Le Filament
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models, api
class ScopBordereauRefundWizard(models.TransientModel):
_name = 'scop.bordereau.refund.wizard'
_description = 'Avoir sur les bordereaux'
bordereau_id = fields.Many2one(
comodel_name='scop.bordereau',
string='Bordereau',
readonly=True,
)
date_refund = fields.Date(
string="Date de régularisation",
default=fields.Date.today())
amount_refund = fields.Float('Montant')
comment = fields.Char('Motif de l\'avoir')
type_cotiz = fields.Selection(
string='Type de cotisation',
selection=lambda self: self._selection_type_cotiz())
# ------------------------------------------------------
# Override ORM
# ------------------------------------------------------
@api.model
def default_get(self, fields):
res = super(ScopBordereauRefundWizard, self).default_get(fields)
bordereau_id = self.env['scop.bordereau'].browse(
self.env.context.get('active_id')
)
res.update({
'bordereau_id': bordereau_id.id,
})
return res
@api.model
def _selection_type_cotiz(self):
bordereau_id = self.env['scop.bordereau'].browse(
self.env.context.get('active_id')
)
contribs = bordereau_id.invoice_ids.read_group(
[('id', 'in', bordereau_id.invoice_ids.ids)],
['type_contribution_id', 'amount_total_signed'],
['type_contribution_id'])
ur_hdf = self.env.ref('cgscop_partner.riga_14232').id
if bordereau_id.partner_id.ur_id.id == ur_hdf:
product_ur = self.env.user.company_id.contribution_hdf_id
else: # ur = ur_med
product_ur = self.env.user.company_id.contribution_med_id
cotiz_type = {
self.env.ref('cgscop_partner.riga_14397').id:
self.env.user.company_id.contribution_cg_id,
self.env.ref('cgscop_partner.riga_14398').id:
self.env.user.company_id.contribution_fede_com_id,
self.env.ref('cgscop_partner.cotiz_fede_cae').id:
self.env.user.company_id.contribution_fede_cae_id,
self.env.ref('cgscop_partner.riga_14399').id:
product_ur,
}
type_cotiz_select_i = list()
type_cotiz_select_list = list()
for contrib in contribs:
type_cotiz = contrib.get('type_contribution_id')[0]
if type_cotiz not in type_cotiz_select_i:
type_cotiz_select_i.append(type_cotiz)
type_cotiz_select_list.append(
(type_cotiz, cotiz_type[type_cotiz].name))
return type_cotiz_select_list
# ------------------------------------------------------
# Action
# ------------------------------------------------------
def create_refund(self):
"""
Create refund
"""
bordereau_id = self.bordereau_id
ur_hdf = self.env.ref('cgscop_partner.riga_14232').id
if bordereau_id.partner_id.ur_id.id == ur_hdf:
product_ur = self.env.user.company_id.contribution_hdf_id
else: # ur = ur_med
product_ur = self.env.user.company_id.contribution_med_id
cotiz_type = {
self.env.ref('cgscop_partner.riga_14397').id:
self.env.user.company_id.contribution_cg_id,
self.env.ref('cgscop_partner.riga_14398').id:
self.env.user.company_id.contribution_fede_com_id,
self.env.ref('cgscop_partner.cotiz_fede_cae').id:
self.env.user.company_id.contribution_fede_cae_id,
self.env.ref('cgscop_partner.riga_14399').id:
product_ur,
}
product = cotiz_type.get(int(self.type_cotiz))
refund = self.env['account.invoice'].create({
'partner_id': bordereau_id.partner_id.id,
'journal_id': self.env.user.company_id.contribution_journal_id.id,
'account_id': bordereau_id.partner_id.property_account_receivable_id.id,
'type': 'out_refund',
'date_invoice': self.date_refund,
'date': self.date_refund,
'state': 'draft',
'number': False,
'origin': bordereau_id.name,
'reference': False,
'bordereau_id': bordereau_id.id,
'is_contribution': True,
'year': bordereau_id.year,
'liasse_fiscale_id': bordereau_id.liasse_fiscale_id.id,
'type_contribution_id': self.type_cotiz,
'payment_mode_id': bordereau_id.payment_mode_id.id,
'date_due': self.date_refund,
})
self.env['account.invoice.line'].create({
'name': self.comment,
'invoice_id': refund.id,
'product_id': product.id,
'account_id': product.property_account_income_id.id,
'price_unit': self.amount_refund
})
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Copyright 2021 Le Filament
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<data>
<record id="scop_bordereau_refund_wizard_form_view" model="ir.ui.view">
<field name="name">scop.bordereau.refund.wizard.form</field>
<field name="model">scop.bordereau.refund.wizard</field>
<field name="arch" type="xml">
<form string="Générer un avoir">
<sheet>
<group string="Nouveaux calculs">
<field name="date_refund" required="1"/>
<separator/>
<field name="amount_refund"/>
<field name="comment"/>
<separator/>
<field name="type_cotiz"/>
</group>
</sheet>
<footer>
<button name="create_refund" type="object" string="Créer l'avoir" class="oe_highlight" confirm="Confirmer la création de l'avoir"/>
<button string="Annuler" special="cancel" class="oe_link"/>
</footer>
</form>
</field>
</record>
<record id="scop_bordereau_refund_wizard_act_window" model="ir.actions.act_window">
<field name="name">Avoir sur le bordereau</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">scop.bordereau.refund.wizard</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</odoo>
\ No newline at end of file
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