summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrhe <rhe@odoo.com>2019-06-06 14:55:59 +0000
committerRobin Heinz <rhe@odoo.com>2019-07-03 12:03:37 +0000
commit541012c9ea7548190eb93d3534bae32d16d76ae8 (patch)
tree427e28c1f25b0607122428d62ca27b5fabe0ea8c
parent7b9bf47d2e943b383c3682bc2e38eec0d73a2e69 (diff)
[FIX] point_of_sale: No payment methods after validating bank statement.
Before the fix, it was possible to validate a bank statement of a POS without validating the entire POS session. After the fix it's impossible to validate the bank statement of an opened POS session. We now have an error message if we try to do it from accounting app and can't see the validate button anymore from the POS app. TASK-ID: 2001551 closes odoo/odoo#33986 Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
-rw-r--r--addons/point_of_sale/models/account_bank_statement.py10
-rw-r--r--addons/point_of_sale/views/account_statement_view.xml11
-rw-r--r--addons/point_of_sale/views/pos_session_view.xml2
3 files changed, 21 insertions, 2 deletions
diff --git a/addons/point_of_sale/models/account_bank_statement.py b/addons/point_of_sale/models/account_bank_statement.py
index 60f7380a32e..b1d8492fb4b 100644
--- a/addons/point_of_sale/models/account_bank_statement.py
+++ b/addons/point_of_sale/models/account_bank_statement.py
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
# Copyright (C) 2004-2008 PC Solutions (<http://pcsol.be>). All Rights Reserved
-from odoo import fields, models
+from odoo import fields, models, api, _
+from odoo.exceptions import UserError
class AccountBankStatement(models.Model):
@@ -10,6 +11,13 @@ class AccountBankStatement(models.Model):
pos_session_id = fields.Many2one('pos.session', string="Session", copy=False)
account_id = fields.Many2one('account.account', related='journal_id.default_debit_account_id', readonly=True)
+ @api.multi
+ def check_confirm_bank(self):
+ for bs in self:
+ if bs.pos_session_id.state in ('opened', 'closing_control') and bs.state == 'open':
+ raise UserError(_("You can't validate a bank statement that is used in an opened Session of a Point of Sale."))
+ return super( AccountBankStatement, self).check_confirm_bank()
+
class AccountBankStatementLine(models.Model):
_inherit = 'account.bank.statement.line'
diff --git a/addons/point_of_sale/views/account_statement_view.xml b/addons/point_of_sale/views/account_statement_view.xml
index f2b00f2e9d4..4efaf7bde0d 100644
--- a/addons/point_of_sale/views/account_statement_view.xml
+++ b/addons/point_of_sale/views/account_statement_view.xml
@@ -19,4 +19,15 @@
</xpath>
</field>
</record>
+
+ <record id="view_bank_statement_pos_session" model="ir.ui.view">
+ <field name="name">view.bank.statement.pos.session</field>
+ <field name="model">account.bank.statement</field>
+ <field name="mode">primary</field>
+ <field name="priority">1000</field>
+ <field name="inherit_id" ref="account.view_bank_statement_form"/>
+ <field name="arch" type="xml">
+ <xpath expr="//button[@name='check_confirm_bank']" position="replace"/>
+ </field>
+ </record>
</odoo>
diff --git a/addons/point_of_sale/views/pos_session_view.xml b/addons/point_of_sale/views/pos_session_view.xml
index df9f67ef641..5d93243e575 100644
--- a/addons/point_of_sale/views/pos_session_view.xml
+++ b/addons/point_of_sale/views/pos_session_view.xml
@@ -120,7 +120,7 @@
</div>
</group>
<separator string="Summary by Payment Methods" attrs="{'invisible' : [('state', '=', 'opening_control')]}"/>
- <field name="statement_ids" attrs="{'invisible' : [('state', '=', 'opening_control')]}">
+ <field name="statement_ids" attrs="{'invisible' : [('state', '=', 'opening_control')]}" context="{'form_view_ref': 'point_of_sale.view_bank_statement_pos_session'}">
<tree string="Statements">
<field name="name" />
<field name="journal_id" />