From 2eb1cde5348c6343fc0bd3fecc33ef7c6cca94ba Mon Sep 17 00:00:00 2001 From: Robin Heinz Date: Thu, 18 Jul 2019 13:17:33 +0000 Subject: [PATCH] [IMP] account, point_of_sale: take money from cash journal When you have a cash journal, you have the opportunity to use a wizard to easily create the statement. There are two wizards, one to add money in the journal, and one to remove money. To simplify the code and remove some duplication, we are now using only one wizard, that will allow to add and/or remove money from the cash journal. TASK-ID: 1934784 --- addons/account/wizard/pos_box.py | 24 ++----------- addons/account/wizard/pos_box.xml | 34 +++---------------- .../point_of_sale/views/pos_session_view.xml | 10 +----- addons/point_of_sale/wizard/pos_box.py | 12 ------- addons/point_of_sale/wizard/pos_box.xml | 9 +---- 5 files changed, 8 insertions(+), 81 deletions(-) diff --git a/addons/account/wizard/pos_box.py b/addons/account/wizard/pos_box.py index 14c12d32dee..3f1e9fe4c00 100644 --- a/addons/account/wizard/pos_box.py +++ b/addons/account/wizard/pos_box.py @@ -5,7 +5,7 @@ class CashBox(models.TransientModel): _register = False name = fields.Char(string='Reason', required=True) - # Attention, we don't set a domain, because there is a journal_type key + # Attention, we don't set a domain, because there is a journal_type key # in the context of the action amount = fields.Float(string='Amount', digits=0, required=True) @@ -36,26 +36,6 @@ class CashBox(models.TransientModel): record.write({'line_ids': [(0, False, values)]}) -class CashBoxIn(CashBox): - _name = 'cash.box.in' - _description = 'Cash Box In' - - ref = fields.Char('Reference') - - def _calculate_values_for_statement_line(self, record): - if not record.journal_id.company_id.transfer_account_id: - raise UserError(_("You have to define an 'Internal Transfer Account' in your cash register's journal.")) - return { - 'date': record.date, - 'statement_id': record.id, - 'journal_id': record.journal_id.id, - 'amount': self.amount or 0.0, - 'account_id': record.journal_id.company_id.transfer_account_id.id, - 'ref': '%s' % (self.ref or ''), - 'name': self.name, - } - - class CashBoxOut(CashBox): _name = 'cash.box.out' _description = 'Cash Box Out' @@ -68,7 +48,7 @@ class CashBoxOut(CashBox): 'date': record.date, 'statement_id': record.id, 'journal_id': record.journal_id.id, - 'amount': -amount if amount > 0.0 else amount, + 'amount': amount, 'account_id': record.journal_id.company_id.transfer_account_id.id, 'name': self.name, } diff --git a/addons/account/wizard/pos_box.xml b/addons/account/wizard/pos_box.xml index f72e2ec902b..d8efbc160ff 100644 --- a/addons/account/wizard/pos_box.xml +++ b/addons/account/wizard/pos_box.xml @@ -1,45 +1,19 @@ - - cash_box_in - cash.box.in - -
- - - - - -
-
- -
-
- - - cash_box_out cash.box.out -
- + +
-
@@ -47,7 +21,7 @@
-