Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DEL] account_payment_pro: Deprecate double-validation #544

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion account_payment_pro/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Account Payment Super Power",
"version": "17.0.1.9.0",
"version": "17.0.2.0.0",
"category": "Payment",
"website": "www.adhoc.com.ar",
"author": "ADHOC SA",
Expand Down
16 changes: 0 additions & 16 deletions account_payment_pro/models/account_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ class AccountPayment(models.Model):
help="Difference between 'To Pay Amount' and 'Payment Total'"
)
write_off_available = fields.Boolean(compute='_compute_write_off_available')
is_approved = fields.Boolean(string="Approved", tracking=True, copy=False,)
use_payment_pro = fields.Boolean(related='company_id.use_payment_pro')

@api.depends('company_id')
Expand All @@ -128,23 +127,12 @@ def _check_to_pay_lines_account(self):
if len(accounts) > 1:
raise ValidationError(_('To Pay Lines must be of the same account!'))

def action_approve(self):
# chequeamos lineas a pagar antes de confirmar pago para evitar idas y vueltas de validacion
self._check_to_pay_lines_account()
self.filtered(lambda x: x.state == 'draft').is_approved = True

def action_unapprove(self):
# chequeamos lineas a pagar antes de confirmar pago para evitar idas y vueltas de validacion
self._check_to_pay_lines_account()
self.filtered(lambda x: x.state == 'draft').is_approved = False

def action_draft(self):
# Seteamos posted_before en true para que nos permita pasar a borrador el pago y poder realizar cambio sobre el mismo
# Nos salteamos la siguente validacion
# https://github.com/odoo/odoo/blob/b6b90636938ae961c339807ea893cabdede9f549/addons/account/models/account_move.py#L2474
if self.company_id.use_payment_pro:
self.posted_before = False
self.is_approved = False
super().action_draft()

@api.model
Expand All @@ -153,8 +141,6 @@ def _get_confimed_blocked_field(self):
'withholdable_advanced_amount', 'company_id', 'to_pay_amount']

def write(self, vals):
if self.filtered('is_approved') and set(self) & set(self._get_confimed_blocked_field()):
raise UserError(_('Your are trying to modify a protected field on an approved payment. Set it back to edit if you want to make this modification.'))
for rec in self:
if rec.company_id.use_payment_pro or ('company_id' in vals and rec.env['res.company'].browse(vals['company_id']).use_payment_pro):
# Lo siguiente lo evaluamos para evitar la validacion de odoo de
Expand Down Expand Up @@ -521,8 +507,6 @@ def check_to_pay_lines(self):
def action_post(self):
res = super().action_post()
for rec in self:
if (rec.is_approved and rec.payment_difference):
raise ValidationError(_('To Pay Amount and Payment Amount must be equal!'))
counterpart_aml = rec.mapped('line_ids').filtered(
lambda r: not r.reconciled and r.account_id.account_type in self._get_valid_payment_account_types())
if counterpart_aml and rec.to_pay_move_line_ids:
Expand Down
6 changes: 0 additions & 6 deletions account_payment_pro/security/payment_security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
<field name="category_id" ref="base.module_category_hidden"/>
<field name="name">Allow pay now on vendor invoices</field>
</record>
<record id="account_confirm_payment" model="res.groups">
<field name="name">Confirm payments (only if double validation is enabled)</field>
<field name="implied_ids" eval="[(4, ref('account.group_account_invoice'))]"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
<field name="category_id" ref="base.module_category_usability"/>
</record>
<record id="account_write_off_type_company_rule" model="ir.rule">
<field name="name">Write Off Type multi-company</field>
<field name="model_id" ref="model_account_write_off_type"/>
Expand Down
42 changes: 1 addition & 41 deletions account_payment_pro/views/account_payment_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,6 @@
</field>
</record>

<record id="view_account_supplier_payment_tree" model="ir.ui.view">
<field name="name">account.payment.tree</field>
<field name="model">account.payment</field>
<field name="inherit_id" ref="account.view_account_supplier_payment_tree"/>
<field name="arch" type="xml">
<header>
<button name="action_approve" string="Approve" groups="account_payment_pro.account_confirm_payment" type="object"/>
</header>
<field name="state" position="after">
<field name="is_approved" optional="hide"/>
</field>
</field>
</record>

<record id="view_account_payment_search" model="ir.ui.view">
<field name="name">account.payment.search</field>
<field name="model">account.payment</field>
<field name="inherit_id" ref="account.view_account_payment_search"/>
<field name="arch" type="xml">
<filter name="date" position='after'>
<separator/>
<filter string="Approved" name="is_approved" domain="[('is_approved', '=', True), ('state', '=', 'draft')]"/>
<filter string="Not approved" name="not_is_approved" domain="[('is_approved', '=', False), ('state', '=', 'draft')]"/>
</filter>
</field>
</record>

<record id="view_account_payment_form" model="ir.ui.view">
<field name="name">account.payment.form</field>
<field name="model">account.payment</field>
Expand All @@ -50,12 +23,11 @@
<form>
<field name="commercial_partner_id" invisible="True"/>
<field name="write_off_available" invisible="True"/>
<field name="is_approved" invisible="True"/>
<field name="use_payment_pro" invisible="True"/>
</form>

<button name="action_post" position="after">
<button name="action_post_and_new" string="Confirm and New" type="object" invisible="is_internal_transfer or state != 'draft' or payment_difference &lt;= 0.0 or not is_approved"/>
<button name="action_post_and_new" string="Confirm and New" type="object" invisible="is_internal_transfer or state != 'draft' or payment_difference &lt;= 0.0"/>
</button>

<xpath expr="//field[@name='partner_id'][1]" position="attributes">
Expand All @@ -70,18 +42,6 @@
<field name="company_id" options="{'no_create': True}" domain="[('id', 'in', allowed_company_ids)]" groups="base.group_multi_company" readonly="state != 'draft' or context.get('default_company_id')"/>
</field>

<xpath expr="//div[@name='button_box']" position="after">
<span class="badge rounded-pill text-bg-success float-end fs-6" invisible="not is_approved">
<i class="fa fa-fw fa-check" aria-label="Approved" title="Approved" role="img"/>
<span class="d-none d-md-inline">Approved</span>
</span>
</xpath>

<button name="action_post" position="before">
<button name="action_approve" class="oe_highlight" string="Approve" groups="account_payment_pro.account_confirm_payment" invisible="state != 'draft'" type="object"/>
<button name="action_unapprove" string="Back to Edit" invisible="state != 'draft' or not is_approved" type="object"/>
</button>

<!-- movemos amount a la columna 2 para que quede todo lo relativo al metodo de pago junto -->
<group name="group2">
<label for="amount" position="move"/>
Expand Down