From 08749777a2cfa20667b9f6ebb8787a2d2acc009f Mon Sep 17 00:00:00 2001 From: raynald Date: Wed, 15 Jun 2022 12:32:42 +0200 Subject: [PATCH] remise en banque --- __manifest__.py | 3 +- models/__init__.py | 2 +- models/bank_deposit.py | 65 ++++++++++++++ models/donation.py | 3 + models/payment_batch.py | 18 +--- report/report.xml | 6 +- report/report_bank_deposit.xml | 126 +++++++++++++++++++++++++++ security/ir.model.access.csv | 2 + views/bank_deposit.xml | 71 +++++++++++++-- views/donation.xml | 16 ++++ views/partner.xml | 4 +- views/payment_batch.xml | 5 +- views/recurring_donation.xml | 8 ++ views/settings.xml | 7 +- wizard/create_bank_deposit_wizard.py | 1 + 15 files changed, 303 insertions(+), 34 deletions(-) create mode 100644 views/donation.xml diff --git a/__manifest__.py b/__manifest__.py index 22f4552..635be44 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -32,6 +32,7 @@ 'views/email.xml', 'views/phone.xml', 'views/partner.xml', + 'views/donation.xml', 'views/recurring_donation.xml', 'data/recurring_donation_configuration.xml', 'data/data.xml', @@ -56,7 +57,7 @@ 'report/report_donation_recurring.xml', 'report/report.xml', 'report/report_donationthanks.xml', - #'report/report_bank_deposit.xml', + 'report/report_bank_deposit.xml', 'views/donation_tax_receipt.xml', 'views/donation_thanks_template.xml', 'views/laposte_ref.xml', diff --git a/models/__init__.py b/models/__init__.py index 5196a65..ca85337 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -27,4 +27,4 @@ from . import partner_import #from . import res_partner_bank from .import donation_print_email_history from .import bank_deposit -from .import accounting_deposit \ No newline at end of file +from .import accounting_deposit diff --git a/models/bank_deposit.py b/models/bank_deposit.py index 19d8c58..b8fd17d 100644 --- a/models/bank_deposit.py +++ b/models/bank_deposit.py @@ -15,10 +15,75 @@ class opendons_bank_deposit(models.Model): ondelete="cascade", default=lambda self: self.env.company, ) + manual_mode_payment_id=fields.Many2one( + "account.payment.mode", + string="manual mode payment", + compute="_compute_manual_mode_payment" + ) + payment_batch_ids = fields.One2many( 'opendons_payment_batch', 'bankdeposit_id', string='Payment batchs', readonly=True ) + @api.model + def _default_currency(self): + company = self.env['res.company']._company_default_get( + 'donation.donation') + return company.currency_id + + currency_id = fields.Many2one( + 'res.currency', + string='Currency', + required=True, + states={'done': [('readonly', True)]}, + track_visibility='onchange', + ondelete='restrict', + default=_default_currency + ) + donation_count=fields.Integer('donation count',compute='_compute_donation_count') + total_amount=fields.Integer('total amount',compute='_compute_total_amount') + # template_bankdeposit_id=fields.Many2one('opendons.template_bankdeposit', 'bank deposit template') + # html_content=fields.Html('html content',compute='_html_content_rf') + # html_content_print=fields.Html('html content print') + def _compute_donation_count(self): + i=0 + for p in self.payment_batch_ids: + for d in p.donation_ids: + for ld in d.line_ids: + i=i+1 + self.donation_count=i-1 + + def _compute_total_amount(self): + i=0 + for p in self.payment_batch_ids: + for d in p.donation_ids: + for ld in d.line_ids: + i=i+ld.amount + self.total_amount=i + + def _compute_manual_mode_payment(self): + manual_method_payment=self.env['account.payment.method'].search([('code','=','manual')],limit=1) + if manual_method_payment: + m=self.env['account.payment.mode'].search([('payment_method_id','=',int(manual_method_payment.id))],limit=1) + if m: + self.manual_mode_payment_id=m.id + def action_print_bankdeposit(self): + self.ensure_one() + + return self.env.ref("opendons.report_bankdeposits").report_action(self) + +class opendons_bank_deposit_template(models.Model): + _name = 'opendons.bankdeposit.template' + _description = 'manage bank deposit template' + + + name=fields.Char('name') + description=fields.Text('description') + active=fields.Boolean('active') + html_page_header=fields.Html('Html page header') + html_page_section=fields.Html('Html page section') + html_page_footer=fields.Html('Html page footer') + \ No newline at end of file diff --git a/models/donation.py b/models/donation.py index a208440..4667ef4 100644 --- a/models/donation.py +++ b/models/donation.py @@ -85,6 +85,9 @@ class DonationDonation(models.Model): ondelete='set null' ) + bank_deposit_date=fields.Datetime('Bank deposit date', related='payment_batch_id.bank_deposit_date') + accounting_deposit_date=fields.Datetime('Accounting deposit date' , related='payment_batch_id.accountingdeposit_date') + year_donation_date=fields.Integer('Year donation date',compute='_compute_year_donation_date',store=True) print_email_history_ids=fields.One2many( 'opendons.donation.print_email_history', diff --git a/models/payment_batch.py b/models/payment_batch.py index e130708..f0f81de 100644 --- a/models/payment_batch.py +++ b/models/payment_batch.py @@ -66,7 +66,7 @@ class opendons_payment_batch(models.Model): string='donation', track_visibility='onchange') - deposited_in_bank=fields.Boolean('deposited in bank') + bank_deposit_date=fields.Datetime(related='bankdeposit_id.create_date') accounting_deposit_date=fields.Datetime(related='accountingdeposit_id.create_date') @@ -247,21 +247,7 @@ class opendons_payment_batch(models.Model): vals['qrcode']=self.payment_input self.env['opendons.payment_batch_qrcode'].create(vals) - # else: - # view_id = self.env.ref('donation.donation_form').id - # context = self._context.copy() - # return { - # 'name':'donation.form', - # 'view_type':'form', - # 'view_mode':'tree', - # 'views' : [(view_id,'form')], - # 'res_model':'donation.donation', - # 'view_id':view_id, - # 'type':'ir.actions.act_window', - # 'res_id':self.id, - # 'target':'new', - # 'context':context, - # } + diff --git a/report/report.xml b/report/report.xml index a40ec87..9bd107e 100644 --- a/report/report.xml +++ b/report/report.xml @@ -43,17 +43,17 @@ report - + \ No newline at end of file diff --git a/report/report_bank_deposit.xml b/report/report_bank_deposit.xml index e69de29..f8b1756 100644 --- a/report/report_bank_deposit.xml +++ b/report/report_bank_deposit.xml @@ -0,0 +1,126 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv index 639c21b..eb6a2e0 100644 --- a/security/ir.model.access.csv +++ b/security/ir.model.access.csv @@ -33,6 +33,7 @@ access_opendons_duplicate_partner,opendons_duplicate_partner,model_opendons_dupl access_opendons_template_rf,opendons_template_rf,model_opendons_template_rf,donation.group_donation_manager,1,1,1,1 +access_opendons_type_template_rf,opendons_type_template_rf,model_opendons_type_template_rf,donation.group_donation_manager,1,1,1,1 access_opendons_donation_thanks_type_template,opendons_donation_thanks_type_template,model_opendons_type_donation_thanks_template,donation.group_donation_manager,1,1,1,1 @@ -56,4 +57,5 @@ access_opendons_create_bank_deposit_wizard,opendons_create_bank_deposit_wizard,m access_opendons_create_accounting_deposit_wizard,opendons_create_accounting_deposit_wizard,model_opendons_createaccountingdeposit,donation.group_donation_manager,1,1,1,1 access_opendons_bank_deposit,opendons_bank_deposit,model_opendons_bankdeposit,donation.group_donation_manager,1,1,1,1 +access_opendons_bank_deposit_template,opendons_bank_deposit_template,model_opendons_bankdeposit_template,donation.group_donation_manager,1,1,1,1 access_opendons_accounting_deposit,opendons_accounting_deposit,model_opendons_accountingdeposit,donation.group_donation_manager,1,1,1,1 \ No newline at end of file diff --git a/views/bank_deposit.xml b/views/bank_deposit.xml index 6c7fbc6..60c3c27 100644 --- a/views/bank_deposit.xml +++ b/views/bank_deposit.xml @@ -21,10 +21,10 @@ opendons.bankdeposit
+
- -
+ @@ -38,9 +38,10 @@ +
-
+
@@ -54,8 +55,68 @@ - + + + + + opendons_template_bankdeposit Form + opendons.bankdeposit.template + +
+ + + + + + + + + + + + + + + +
+
+
+ + + opendons_template_bankdeposit List + opendons.bankdeposit.template + + + + + + + + + + + + + Bank deposit templates + opendons.bankdeposit.template + tree,form + + + + + + + \ No newline at end of file diff --git a/views/donation.xml b/views/donation.xml new file mode 100644 index 0000000..dcd7fda --- /dev/null +++ b/views/donation.xml @@ -0,0 +1,16 @@ + + + + opendons.donation.tree + donation.donation + + + + + + + + + + + \ No newline at end of file diff --git a/views/partner.xml b/views/partner.xml index 827b75b..e58b4d7 100644 --- a/views/partner.xml +++ b/views/partner.xml @@ -195,9 +195,9 @@ - + diff --git a/views/payment_batch.xml b/views/payment_batch.xml index dfd89b4..54a3a9d 100644 --- a/views/payment_batch.xml +++ b/views/payment_batch.xml @@ -8,7 +8,7 @@ - +