summaryrefslogtreecommitdiff
path: root/addons/point_of_sale/wizard/pos_open_statement.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/point_of_sale/wizard/pos_open_statement.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/point_of_sale/wizard/pos_open_statement.py')
-rw-r--r--addons/point_of_sale/wizard/pos_open_statement.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/addons/point_of_sale/wizard/pos_open_statement.py b/addons/point_of_sale/wizard/pos_open_statement.py
new file mode 100644
index 00000000..f6049bf5
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_open_statement.py
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import api, models, _
+from odoo.exceptions import UserError
+
+
+class PosOpenStatement(models.TransientModel):
+ _name = 'pos.open.statement'
+ _description = 'Point of Sale Open Statement'
+
+ def open_statement(self):
+ self.ensure_one()
+ BankStatement = self.env['account.bank.statement']
+ journals = self.env['account.journal'].search([('journal_user', '=', True)])
+ if not journals:
+ raise UserError(_('You have to define which payment method must be available in the point of sale by reusing existing bank and cash through "Accounting / Configuration / Journals / Journals". Select a journal and check the field "PoS Payment Method" from the "Point of Sale" tab. You can also create new payment methods directly from menu "PoS Backend / Configuration / Payment Methods".'))
+
+ for journal in journals:
+ if journal.sequence_id:
+ number = journal.sequence_id.next_by_id()
+ else:
+ raise UserError(_("No sequence defined on the journal"))
+ BankStatement += BankStatement.create({'journal_id': journal.id, 'user_id': self.env.uid, 'name': number})
+
+ tree_id = self.env.ref('account.view_bank_statement_tree').id
+ form_id = self.env.ref('account.view_bank_statement_form').id
+ search_id = self.env.ref('account.view_bank_statement_search').id
+
+ return {
+ 'type': 'ir.actions.act_window',
+ 'name': _('List of Cash Registers'),
+ 'view_mode': 'tree,form',
+ 'res_model': 'account.bank.statement',
+ 'domain': str([('id', 'in', BankStatement.ids)]),
+ 'views': [(tree_id, 'tree'), (form_id, 'form')],
+ 'search_view_id': search_id,
+ }