diff --git a/gn_cash/README.md b/gn_cash/README.md new file mode 100644 index 0000000..e5236f3 --- /dev/null +++ b/gn_cash/README.md @@ -0,0 +1,23 @@ +# GN-CASH + +This modules revivals cash statements from Odoo 15. + +It adds a wizard for cashbox counting after balance_start an balance_end_real fields of bank.statement form view. + +It is based on modules: +- (account_statement_base from OCA)[https://github.com/OCA/account-reconcile] + +## How do we work with it: + +1. Each day, users create operations they assume (like receive donation, etc.) +2. If time is short, they can also declare it on a simple solo statement line +3. At the end of the week, Odoo generates a statement with missing lines (i.e. lines with payment suspense accounts) +4. the accountant verifies cashbox balance and validate loss/profit + + +## Whats Needs to Be Done: + +- add validate cashbox and entry lines creation +- allow user to add statement lines 'on-the-fly' +- allow user to create Donation / Expense / Cash-In / Cash-Out operations +- create an action triggered by a button leading to a wizard that auto-generates cash statement from lines with payment suspense account. diff --git a/gn_cash/__manifest__.py b/gn_cash/__manifest__.py index 221131a..4daf3d0 100644 --- a/gn_cash/__manifest__.py +++ b/gn_cash/__manifest__.py @@ -6,13 +6,10 @@ 'description': """ This module revivals cash statements from odoo 15. """, - 'depends': ['account_reconcile_oca', 'account_statement_import_sheet_file'], + 'depends': ['account_statement_base'], 'data': [ 'security/ir.model.access.csv', - 'views/delete_views.xml', - 'views/account_journal_views.xml', 'views/account_cash_statement_views.xml', - 'views/account_journal_dashboard_view.xml', 'views/cash_statement_views.xml', ], 'translate': True, diff --git a/gn_cash/models/__init__.py b/gn_cash/models/__init__.py index 8ee686b..b757ee5 100644 --- a/gn_cash/models/__init__.py +++ b/gn_cash/models/__init__.py @@ -1,4 +1,4 @@ # -*- coding: utf-8 -*- from . import cash_statement -#, account_journal_dashboard \ No newline at end of file +#account_journal_dashboard \ No newline at end of file diff --git a/gn_cash/models/account_journal_dashboard.py b/gn_cash/models/account_journal_dashboard.py deleted file mode 100644 index ecf0908..0000000 --- a/gn_cash/models/account_journal_dashboard.py +++ /dev/null @@ -1,90 +0,0 @@ -from odoo import models, api, _, fields -from odoo.exceptions import UserError -import ast - -class account_journal(models.Model): - _inherit = "account.journal" - def _select_action_to_open(self): - self.ensure_one() - if self._context.get('action_name'): - return self._context.get('action_name') - elif self.type == 'bank': - return 'account.action_bank_statement_tree' - elif self.type == 'cash': - #return 'gn_cash.action_cash_statement_tree' - return 'account.action_view_bank_statement_tree' - elif self.type == 'sale': - return 'account.action_move_out_invoice_type' - elif self.type == 'purchase': - return 'account.action_move_in_invoice_type' - else: - return 'account.action_move_journal_line' - - def create_cash_statement(self): - """return action to create a cash statements.""" - action = self.env["ir.actions.actions"]._for_xml_id("gn_cash.action_cash_statement_tree") - action.update({ - 'views': [(self.env.ref('gn_cash.view_cash_statement_form').id, 'form')], - 'context': { - 'default_journal_id': str(self.id), - 'journal_type': str(self.type), - } - }) - return action - - - def open_action(self): - """return action based on type for related journals""" - self.ensure_one() - action_name = self._select_action_to_open() - - # Set 'account.' prefix if missing. - #if not action_name.startswith("account."): - # action_name = 'account.%s' % action_name - - action = self.env["ir.actions.act_window"]._for_xml_id(action_name) - - context = self._context.copy() - if 'context' in action and isinstance(action['context'], str): - context.update(ast.literal_eval(action['context'])) - else: - context.update(action.get('context', {})) - action['context'] = context - action['context'].update({ - 'default_journal_id': self.id, - }) - domain_type_field = action['res_model'] == 'account.move.line' and 'move_id.move_type' or 'move_type' # The model can be either account.move or account.move.line - - # Override the domain only if the action was not explicitly specified in order to keep the - # original action domain. - if action.get('domain') and isinstance(action['domain'], str): - action['domain'] = ast.literal_eval(action['domain'] or '[]') - if not self._context.get('action_name'): - if self.type == 'sale': - action['domain'] = [(domain_type_field, 'in', ('out_invoice', 'out_refund', 'out_receipt'))] - elif self.type == 'purchase': - action['domain'] = [(domain_type_field, 'in', ('in_invoice', 'in_refund', 'in_receipt', 'entry'))] - - action['domain'] = (action['domain'] or []) + [('journal_id', '=', self.id)] - return action - - - def open_action_with_context(self): - action_name = self.env.context.get('action_name', False) - if not action_name: - return False - ctx = dict(self.env.context, default_journal_id=self.id) - if ctx.get('search_default_journal', False): - ctx.update(search_default_journal_id=self.id) - ctx['search_default_journal'] = False # otherwise it will do a useless groupby in bank statements - ctx.pop('group_by', None) - action = self.env['ir.actions.act_window']._for_xml_id(action_name) - action['context'] = ctx - if ctx.get('use_domain', False): - action['domain'] = isinstance(ctx['use_domain'], list) and ctx['use_domain'] or ['|', ('journal_id', '=', self.id), ('journal_id', '=', False)] - action['name'] = _( - "%(action)s for journal %(journal)s", - action=action["name"], - journal=self.name, - ) - return action \ No newline at end of file diff --git a/gn_cash/models/cash_statement.py b/gn_cash/models/cash_statement.py index 3aac759..ac873be 100644 --- a/gn_cash/models/cash_statement.py +++ b/gn_cash/models/cash_statement.py @@ -95,9 +95,14 @@ class AccountBankStmtCloseCheck(models.TransientModel): """ Account Bank Statement wizard that check that closing balance is correct. """ - _name = 'account.bank.statement.closebalance' + _name = 'gn_cash.account.bank.statement.closebalance' _description = 'Bank Statement Closing Balance' + """ + Warning!! This method is not linked to effective operations. + We need to figure out what to do with difference found beetween calculated total and wizard total + i.e. which moves need to be created + """ def validate(self): bnk_stmt_id = self.env.context.get('active_id', False) if bnk_stmt_id: @@ -110,6 +115,9 @@ class BankStatement(models.Model): cashbox_start_id = fields.Many2one('gn_cash.account.bank.statement.cashbox', string="Starting Cashbox") cashbox_end_id = fields.Many2one('gn_cash.account.bank.statement.cashbox', string="Ending Cashbox") + + #This is the function we need to verify in order to have a functionnal validate on wizard + def _check_cash_balance_end_real_same_as_computed(self): """ Check the balance_end_real (encoded manually by the user) is equals to the balance_end (computed by odoo). For a cash statement, if there is a difference, the different is set automatically to a profit/loss account. diff --git a/gn_cash/views/account_cash_statement_views.xml b/gn_cash/views/account_cash_statement_views.xml index da717b4..cd1b6e5 100644 --- a/gn_cash/views/account_cash_statement_views.xml +++ b/gn_cash/views/account_cash_statement_views.xml @@ -1,85 +1,7 @@ - - gn_cash.account.cash.statement.form - account.bank.statement - 1 - -
- - -
-
-
-
- - - - - - - - - - - - - - - - - -
- - - - - - + Cash Logs account.bank.statement tree,form,pivot,graph @@ -96,29 +18,19 @@

- - - tree - - - - - - form - - - - - - tree - - - - - - form - - - + + gn_cash.account.cash.statement.form + account.bank.statement + + 100 + + + - - - - - - - - - - \ No newline at end of file diff --git a/gn_cash/views/account_journal_views.xml b/gn_cash/views/account_journal_views.xml deleted file mode 100644 index c923f1d..0000000 --- a/gn_cash/views/account_journal_views.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - gn_cash.account.journal.form - account.journal - - - - - - - - - - - - \ No newline at end of file diff --git a/gn_cash/views/cash_statement_views.xml b/gn_cash/views/cash_statement_views.xml index 9f25c19..b8c55c7 100644 --- a/gn_cash/views/cash_statement_views.xml +++ b/gn_cash/views/cash_statement_views.xml @@ -1,7 +1,7 @@ - + gn_cash.account.bnk_stmt_cashbox.form gn_cash.account.bank.statement.cashbox @@ -31,12 +31,12 @@ - + gn_cash.account.bnk_stmt_cashbox.form gn_cash.account.bank.statement.cashbox 1000 primary - +