From 5e4fddae80ca3f84b59026009f54f2a8fe7102d8 Mon Sep 17 00:00:00 2001 From: makayabou Date: Thu, 8 Aug 2024 13:38:14 +0200 Subject: [PATCH] add cash order - deposit creation from dashboard --- gn_cash/README.md | 19 +++++++----- gn_cash/__manifest__.py | 2 +- gn_cash/models/account_cash_deposit.py | 9 ++++++ gn_cash/models/account_journal_dashboard.py | 31 +++++++++++++++++++ gn_cash/views/account_cash_deposit_views.xml | 7 +++++ .../views/account_journal_dashboard_view.xml | 1 + 6 files changed, 60 insertions(+), 9 deletions(-) diff --git a/gn_cash/README.md b/gn_cash/README.md index 95335ac..97caebc 100644 --- a/gn_cash/README.md +++ b/gn_cash/README.md @@ -20,14 +20,17 @@ It is based on modules: ## Whats Needs to Be Done: -- [x] add validate cashbox and entry lines creation -- [x] loss/profit validation -- [x] use predefined cash units -- [x] sequencing on statement gen -- [x] add button on payment to access statement if is_matched -- [x] add orphan statement lines in the next gen statement -- [x] add partner in deposit and move -- [x] use suspense account +- [x] add validate cashbox and entry lines creation | 16.0.0.0.1 +- [x] loss/profit validation | 16.0.0.0.2 +- [x] use predefined cash units | 16.0.0.0.3 +- [x] sequencing on statement gen | 16.0.0.0.4 +- [x] add button on payment to access statement if is_matched |16.0.0.0.5 +- [x] add orphan statement lines in the next gen statement | 16.0.0.0.6 +- [x] add partner in deposit and move | 16.0.0.0.7 +- [x] use suspense account | 16.0.0.0.7 +- [x] add button in dashboard to create a deposit / order | 16.0.0.0.8 +- [x] add some defaults (date, default_lines) at deposit creation | 16.0.0.0.8 +- [] add default cash units for cash order - [] choose beetween bank and cash journal for a deposit - [] add a button to put directly the cash order from bank to cash - [] add cash deposits / cash outs to statement diff --git a/gn_cash/__manifest__.py b/gn_cash/__manifest__.py index c649c9f..5432436 100644 --- a/gn_cash/__manifest__.py +++ b/gn_cash/__manifest__.py @@ -1,6 +1,6 @@ { 'name': "Gn Cash", - 'version': '16.0.0.0.7', + 'version': '16.0.0.0.8', 'author': 'Garage Numérique', 'category': 'Accounting', 'description': """ diff --git a/gn_cash/models/account_cash_deposit.py b/gn_cash/models/account_cash_deposit.py index ca79b46..b0215d5 100644 --- a/gn_cash/models/account_cash_deposit.py +++ b/gn_cash/models/account_cash_deposit.py @@ -13,6 +13,15 @@ class AccountCashDeposit(models.Model): ondelete='restrict', ) + operation_type = fields.Selection( + [ + ("deposit", "Cash Deposit"), + ("order", "Cash Order"), + ], + required=True, + readonly=False, + ) + @api.onchange('partner_id') def _compute_partner_id(self): for deposit in self: diff --git a/gn_cash/models/account_journal_dashboard.py b/gn_cash/models/account_journal_dashboard.py index a640c42..629ebac 100644 --- a/gn_cash/models/account_journal_dashboard.py +++ b/gn_cash/models/account_journal_dashboard.py @@ -8,6 +8,37 @@ _logger = logging.getLogger(__name__) class AccountJournal(models.Model): _inherit = "account.journal" + def cash_in_or_out(self): + for journal in self: + journal.ensure_one() + + # Create deposit + deposit = self.env['account.cash.deposit'].create({ + 'operation_type': 'order', + 'date': fields.Date.today(), + 'cash_journal_id': journal.id, + 'bank_journal_id': journal.id, + 'currency_id': self.env.company.currency_id.id + }) + + # Add default lines + cash_units = self.env["cash.unit"].search( + [ + ("auto_create", "in", ("both", 'deposit')), + ("currency_id", "=", deposit.currency_id.id), + ] + ) + deposit.line_ids = [(0, 0, { + "cash_unit_id": cunit.id, + "qty": 0, + "currency_id": deposit.currency_id.id}) for cunit in cash_units ] + + # Call form view + action = self.env['ir.actions.act_window']._for_xml_id('gn_cash.account_cash_inorout_action') + action['res_id'] = deposit.id + return action + + def generate_statement_line_from_payment(self, payment_id): payment = self.env['account.payment'].browse(payment_id) stmt_line_values = { diff --git a/gn_cash/views/account_cash_deposit_views.xml b/gn_cash/views/account_cash_deposit_views.xml index b4b0517..9acfd20 100644 --- a/gn_cash/views/account_cash_deposit_views.xml +++ b/gn_cash/views/account_cash_deposit_views.xml @@ -11,8 +11,15 @@ + + + Cash Deposit + account.cash.deposit + form + + \ No newline at end of file diff --git a/gn_cash/views/account_journal_dashboard_view.xml b/gn_cash/views/account_journal_dashboard_view.xml index b4f0cba..1ea1dd6 100644 --- a/gn_cash/views/account_journal_dashboard_view.xml +++ b/gn_cash/views/account_journal_dashboard_view.xml @@ -10,6 +10,7 @@
Nouveau Relevé + Cash In/Out