Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] add new module account_cashbox_l10n_latam_check
closes #414 Signed-off-by: Juan José Scarafía <jjs@adhoc.com.ar>
- Loading branch information
Showing
5 changed files
with
87 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import wizards |
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,21 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Check Cashbox management", | ||
"summary": "Add cashbox for check operations", | ||
"version": "16.0.1.0.1", | ||
"category": "Accounting", | ||
"website": "www.adhoc.com.ar", | ||
"author": "ADHOC SA", | ||
"license": "AGPL-3", | ||
"depends": [ | ||
"account_cashbox", | ||
"l10n_latam_check", | ||
], | ||
"demo": [], | ||
"data": [ | ||
'wizards/l10n_latam_payment_mass_transfer_views.xml', | ||
], | ||
"installable": True, | ||
"application": False, | ||
"auto_install": True, | ||
} |
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 @@ | ||
from . import l10n_latam_payment_mass_transfer |
45 changes: 45 additions & 0 deletions
45
account_cashbox_l10n_latam_check/wizards/l10n_latam_payment_mass_transfer.py
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,45 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from odoo import models, api, fields, _ | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class L10nLatamPaymentMassTransfer(models.TransientModel): | ||
_inherit = 'l10n_latam.payment.mass.transfer' | ||
|
||
cashbox_session_id = fields.Many2one( | ||
'account.cashbox.session', | ||
string='POP Session', | ||
compute="_compute_cashbox_session_id", | ||
readonly=False, | ||
store=True | ||
) | ||
requiere_account_cashbox_session = fields.Boolean( | ||
compute='_compute_requiere_account_cashbox_session', | ||
compute_sudo=False, | ||
) | ||
|
||
@api.depends_context('uid') | ||
# dummy depends para que se compute(no estamos seguros porque solo con el depends_context no computa) | ||
@api.depends('destination_journal_id') | ||
def _compute_requiere_account_cashbox_session(self): | ||
self.requiere_account_cashbox_session = self.env.user.requiere_account_cashbox_session | ||
|
||
def _compute_cashbox_session_id(self): | ||
for rec in self: | ||
session_ids = self.env['account.cashbox.session'].search([ | ||
('user_ids', '=', self.env.uid), | ||
('state', '=', 'opened') | ||
]) | ||
if len(session_ids) == 1: | ||
rec.cashbox_session_id = session_ids.id | ||
else: | ||
rec.cashbox_session_id = False | ||
|
||
def _create_payments(self): | ||
self.ensure_one() | ||
if self.env.user.requiere_account_cashbox_session and not self.cashbox_session_id: | ||
raise UserError(_('Your user requires to use payment session on each tranfer')) | ||
payments = super()._create_payments() | ||
payments.cashbox_session_id = self.cashbox_session_id.id | ||
return payments |
19 changes: 19 additions & 0 deletions
19
account_cashbox_l10n_latam_check/wizards/l10n_latam_payment_mass_transfer_views.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,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<record id="view_l10n_latam_payment_mass_transfer_form" model="ir.ui.view"> | ||
<field name="name">l10n_latam.payment.mass.transfer.form</field> | ||
<field name="model">l10n_latam.payment.mass.transfer</field> | ||
<field name="inherit_id" ref="l10n_latam_check.view_l10n_latam_payment_mass_transfer_form"/> | ||
<field name="arch" type="xml"> | ||
<field name="destination_journal_id" position="after"> | ||
<field name="requiere_account_cashbox_session" invisible="1"/> | ||
<!-- filtramos por usuario para que a los admin solo les aparezcan en donde estan involucrados. Total siendo admin se pueden agregar en la que quieran --> | ||
<field | ||
name="cashbox_session_id" | ||
domain="[('user_ids', '=', uid), ('state', '=', 'opened'), ('company_id', '=', company_id)]" | ||
attrs="{'required': [('requiere_account_cashbox_session', '=', True)]}" | ||
/> | ||
</field> | ||
</field> | ||
</record> | ||
</odoo> |