-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] l10n_ar_edi_ux: agregar funcionalidad de debitar cheques propios.
Tarea: 34995 Lo hacemos acá y no en l10n_ar_ux porque no tenemos enterprise y usamos acá un metodo de account_accountant.
- Loading branch information
1 parent
391993c
commit 0d41392
Showing
9 changed files
with
116 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<odoo> | ||
|
||
<record id="view_account_payment_form_inherited" model="ir.ui.view"> | ||
<field name="name">account.payment.form.inherited</field> | ||
<field name="model">account.payment</field> | ||
<field name="inherit_id" ref="account.view_account_payment_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//button[@name='action_post']" position="after"> | ||
<button name="%(action_debit_check_wizard)d" string="Debit check" type="action" attrs="{'invisible': ['|', '|', '|',('payment_method_code', '!=', 'check_printing'), ('state', '!=', 'posted'), ('is_move_sent', '=', False), ('is_matched', '=', True)]}"/> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
############################################################################## | ||
# For copyright and license notices, see __manifest__.py file in module root | ||
# directory | ||
############################################################################## | ||
from odoo import fields, models, _ | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class AccountCheckActionWizard(models.TransientModel): | ||
_name = 'account.check.action.wizard' | ||
_description = 'Account Check Action Wizard' | ||
|
||
date = fields.Date( | ||
default=fields.Date.context_today, | ||
required=True, | ||
) | ||
|
||
def action_confirm(self): | ||
""" Este método sirve para hacer el débito de cheques con cuenta outstanding desde los payments con método de pago de cheques. """ | ||
payment = self.env['account.payment'].browse(self._context.get('active_id', False)) | ||
if self.date < payment.date: | ||
raise ValidationError(f'La fecha del débito del cheque {self.date} no puede ser inferior a la fecha de emisión del mismo {payment.date}.') | ||
# Línea del cheque a conciliar. | ||
move_line_ids = [payment.line_ids.filtered(lambda x: not x.reconciled).id] | ||
# Obtenemos la cuenta outstanding del método de pago pentientes "manual" del diario del pago o bien la "Cuenta de pagos pentientes" de la compañía. | ||
outstanding_account = self._get_outstanding_account(payment) | ||
# Obtenemos fecha, importe, pasamos cuenta outstanding y el diario es de tipo varios que está vinculado al diario del pago del cheque (ver campo Check Debit Journal en el diario) para que nos permita hacer la conciliación. Lo utilizamos como un diario "puente". | ||
new_mv_line_dicts = [{'name': f'Débito cheque nro {payment.check_number}', | ||
'balance': abs(payment.line_ids.filtered(lambda x: not x.reconciled).balance), | ||
'account_id': outstanding_account.id, | ||
'journal_id': payment.journal_id.check_debit_journal_id.id, | ||
'date': self.date, | ||
}] | ||
self.env['account.reconciliation.widget']._process_move_lines(move_line_ids, new_mv_line_dicts) | ||
payment.message_post(body=f'El cheque nro "{payment.check_number}" ha sido debitado.') | ||
|
||
def _get_outstanding_account(self, payment): | ||
""" Obtenemos la cuenta outstanding para hacer el débito de cheques y hacemos las validaciones correspondientes. """ | ||
journal = payment.journal_id | ||
journal_manual_payment_method = journal.outbound_payment_method_line_ids.filtered(lambda x: x.code=='manual') | ||
company_outstanding_payment_account = journal.company_id.account_journal_payment_credit_account_id | ||
outstanding_account = journal_manual_payment_method.payment_account_id or company_outstanding_payment_account | ||
if not outstanding_account: | ||
raise ValidationError(f'No existe método de pago manual en el diario {journal.display_name} ni "Cuenta de pagos pendientes" establecida para la compañìa {journal.company_id.display_name}.') | ||
if journal_manual_payment_method.payment_account_id and not journal_manual_payment_method.payment_account_id.reconcile: | ||
raise ValidationError(f'La "Cuenta de pagos pendientes" del método de pago pentientes "Manual" del diario {journal.display_name} no permite realizar conciliación. Usar cuenta "outstanding".') | ||
if company_outstanding_payment_account and not company_outstanding_payment_account.reconcile: | ||
raise ValidationError(f'La cuenta "Cuenta de pagos pendientes" de la compañía {journal.company_id.display_name} no permite realizar conciliación. Usar cuenta "outstanding".') | ||
return outstanding_account |
28 changes: 28 additions & 0 deletions
28
l10n_ar_edi_ux/wizards/account_check_action_wizard_view.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record model="ir.ui.view" id="account_check_action_wizard_form_view"> | ||
<field name="name">account.check.action.wizard.form</field> | ||
<field name="model">account.check.action.wizard</field> | ||
<field name="arch" type="xml"> | ||
<form string="Check Action"> | ||
<group > | ||
<field name="date"/> | ||
</group> | ||
<footer> | ||
<button string="Confirm" name="action_confirm" type="object" class="oe_highlight"/> | ||
or | ||
<button string="Cancel" class="oe_link" special="cancel"/> | ||
</footer> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record id="action_debit_check_wizard" model="ir.actions.act_window"> | ||
<field name="name">Check Action</field> | ||
<field name="res_model">account.check.action.wizard</field> | ||
<field name="view_mode">form</field> | ||
<field name="target">new</field> | ||
</record> | ||
|
||
</odoo> |