From cd588fcb12971dd31d1ebcf974ff6a60b056cdb7 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 25 May 2022 15:14:03 +0000 Subject: [PATCH] thanks letter et RF --- __manifest__.py | 4 ++ data/data.xml | 25 +++++++++ i18n/fr.po | 4 +- models/__init__.py | 1 + models/donation.py | 22 +++++++- models/donation_tax_receipt.py | 87 +++++++++++++++++++++++++++++- models/donation_thanks_template.py | 16 ++++++ models/settings.py | 1 + models/template_rf.py | 9 +++- report/report.xml | 14 +++++ report/report_donationtax.xml | 24 ++++----- report/report_donationthanks.xml | 27 ++++++++++ security/ir.model.access.csv | 2 + views/donation_thanks_template.xml | 40 ++++++++++++++ views/recurring_donation.xml | 8 +-- views/settings.xml | 7 +++ views/template_rf.xml | 2 + 17 files changed, 269 insertions(+), 24 deletions(-) create mode 100644 data/data.xml create mode 100644 models/donation_thanks_template.py create mode 100644 report/report_donationthanks.xml create mode 100644 views/donation_thanks_template.xml diff --git a/__manifest__.py b/__manifest__.py index d650283..7157fe7 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -34,6 +34,7 @@ 'views/partner.xml', 'views/recurring_donation.xml', 'data/recurring_donation_configuration.xml', + 'data/data.xml', 'views/relationship.xml', 'views/operation.xml', 'views/templates.xml', @@ -50,11 +51,14 @@ 'report/report_donationtax.xml', 'report/report_donation_recurring.xml', 'report/report.xml', + 'report/report_donationthanks.xml', 'views/donation_tax_receipt.xml', + 'views/donation_thanks_template.xml', 'views/laposte_ref.xml', 'views/partner_import.xml', 'views/portal.xml', 'data/donation_recurring_mail_template.xml' + #'views/website_donation.xml' diff --git a/data/data.xml b/data/data.xml new file mode 100644 index 0000000..c086e4d --- /dev/null +++ b/data/data.xml @@ -0,0 +1,25 @@ + + + + + generic + + + affectation + + + high amount + + + + generic + + + affectation + + + high amount + + + + \ No newline at end of file diff --git a/i18n/fr.po b/i18n/fr.po index e769fef..ae6ae3e 100644 --- a/i18n/fr.po +++ b/i18n/fr.po @@ -482,7 +482,7 @@ msgstr "Domaine" #. module: opendons #: model:ir.model,name:opendons.model_donation_donation msgid "Donation" -msgstr "Don" +msgstr "Dons" #. module: opendons #: model:ir.model.fields,field_description:opendons.field_sale_order__donation_amount @@ -1638,7 +1638,7 @@ msgstr "" #. module: opendons #: model:ir.model.fields,field_description:opendons.field_opendons_payment_batch__donation_ids msgid "donation" -msgstr "don" +msgstr "dons" #. module: opendons #: model:ir.model,name:opendons.model_opendons_duplicate_partner diff --git a/models/__init__.py b/models/__init__.py index 366d54d..54f0b22 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -19,6 +19,7 @@ from . import donation_tax_receipt from . import laposte_ref from . import settings from . import donation_recurring_template_letter +from . import donation_thanks_template from . import partner_import #from . import res_partner_bank from .import donation_print_email_history \ No newline at end of file diff --git a/models/donation.py b/models/donation.py index 150fe0a..46721b5 100644 --- a/models/donation.py +++ b/models/donation.py @@ -92,6 +92,8 @@ class DonationDonation(models.Model): string='print or email history ', readonly=True ) + html_content_print=fields.Html('html content print') + def _compute_year_donation_date(self): for rec in self: @@ -621,8 +623,26 @@ class DonationDonation(models.Model): res.append((donation.id, name)) return res + def print_thanks(self): + self.ensure_one() + self.write({"thanks_printed": True}) + + html_content_print=self.thanks_template_id.html_content + html_content_print=html_content_print.replace('{{partner_id.name}}',self.partner_id.name) + html_content_print=html_content_print.replace('{{partner_id.firstname}}',self.partner_id.firstname) + html_content_print=html_content_print.replace('{{adresse}}',self.env['donation.tax.receipt'].update_adresse()) + html_content_print=html_content_print.replace('{{donor_id}}',self.partner_id.donor_id) + self.html_content_print=html_content_print + + + return self.env.ref("opendons.report_donation_thanks").report_action(self) + class DonationLine(models.Model): _inherit = 'donation.line' donation_date=fields.Date(related='donation_id.donation_date') - partner_id=fields.Many2one(related='donation_id.partner_id') \ No newline at end of file + partner_id=fields.Many2one(related='donation_id.partner_id') + + + + \ No newline at end of file diff --git a/models/donation_tax_receipt.py b/models/donation_tax_receipt.py index 28383ab..70833d4 100644 --- a/models/donation_tax_receipt.py +++ b/models/donation_tax_receipt.py @@ -7,6 +7,34 @@ class DonationTaxReceipt(models.Model): template_rf_id=fields.Many2one('opendons.template_rf', 'RF template') html_content=fields.Html('html content',compute='_html_content_rf') html_content_print=fields.Html('html content print') + #donation_type=fields.Char('letter', compute='_compute_donation_type') + + + + # #res = super(DonationTaxReceipt, self).create(vals) + # def _compute_donation_type(self): + + # if len(self.donation_ids)>1: + # #1 cas d'un RF à plusieurs dons + # simple=True + # i=1 + # for d in self.donation_ids: + # for l in d.donation_lines: + # if i==1: product_id=l.product_id + # else: + # if product_id!=l.product_id: + # simple=False + # break + # i=i+1 + # if simple==True : + # self.donation_type='simple' + # self.product_id=product_id + # if simple==False : + # self.donation_type='multiple' + # self.product_id=False + + + def get_portal_url(self): return "my/taxreceipt/print?id="+str(self.id) @@ -17,6 +45,8 @@ class DonationTaxReceipt(models.Model): html_content_print=self.html_content html_content_print=html_content_print.replace('{{partner_id.name}}',self.partner_id.name) html_content_print=html_content_print.replace('{{partner_id.firstname}}',self.partner_id.firstname) + html_content_print=html_content_print.replace('{{adresse}}',self.update_adresse()) + html_content_print=html_content_print.replace('{{donor_id}}',self.partner_id.donor_id) self.html_content_print=html_content_print #self.env['donation.tax_receipt'].write(vals) @@ -27,8 +57,63 @@ class DonationTaxReceipt(models.Model): def _html_content_rf(self): self.html_content=self.template_rf_id.html_content + #affichage du RF depuis l'espace donateur def update_print_pdf(self): html_content_print=self.html_content html_content_print=html_content_print.replace('{{partner_id.name}}',self.partner_id.name) html_content_print=html_content_print.replace('{{partner_id.firstname}}',self.partner_id.firstname) - self.html_content_print=html_content_print \ No newline at end of file + html_content_print=html_content_print.replace('{{donor_id}}',self.partner_id.donor_id) + html_content_print=html_content_print.replace('{{adresse}}',self.update_adresse()) + + self.html_content_print=html_content_print + + def update_adresse(self): + p=self.env['res.partner'].search([('id','=',int(self.partner_id))]) + result='' + #prise en compte de l'adresse fiscale ou non + if p.tax_street and p.tax_zip and p.city: + title=p.title.name if p.title.name else '' + name=p.name if p.name else '' + firstname=p.firstname if p.firstname else '' + street=p.tax_street if p.tax_street else '' + street2='
'+p.tax_street2 if p.tax_street2 else '' + locality='
'+p.tax_locality if p.tax_locality else '' + zip=p.tax_zip if p.tax_zip else '' + city=p.tax_city if p.tax_city else '' + country=p.tax_country_id.name if p.tax_country_id.name else '' + + result='

'+title+' '+name+' '+firstname+'
'+street+street2+locality+'
'+zip+' '+city+'
'+country+'

' + else: + title=p.title.name if p.title.name else '' + name=p.name if p.name else '' + firstname=p.firstname if p.firstname else '' + street=p.street if p.street else '' + street2='
'+p.street2 if p.street2 else '' + locality='
'+p.locality if p.locality else '' + zip=p.zip if p.zip else '' + city=p.city if p.city else '' + country=p.country_id.name if p.country_id.name else '' + + result='

'+title+' '+name+' '+firstname+'
'+street+street2+locality+'
'+zip+' '+city+'
'+country+'

' + + #result="

Monsieur Dupont Marcel
7 avenue de la Marne

75016 Paris

" + return result + +class DonationTaxReceiptPrint(models.TransientModel): + _inherit = "donation.tax.receipt.print" + + + def print_receipts(self): + self.ensure_one() + if not self.receipt_ids: + raise UserError(_("There are no tax receipts to print.")) + today = fields.Date.context_today(self) + #self.receipt_ids.write({"print_date": today}) + + #update htm to print in receipts + for receipt_id in self.receipt_ids: + + receipt_id.update_print_pdf() + + + return self.env.ref("opendons.report_donation_tax_receipt").report_action(self.receipt_ids) \ No newline at end of file diff --git a/models/donation_thanks_template.py b/models/donation_thanks_template.py new file mode 100644 index 0000000..670af0a --- /dev/null +++ b/models/donation_thanks_template.py @@ -0,0 +1,16 @@ +from odoo import fields, models + + +class DonationThanksTemplate(models.Model): + _inherit = "donation.thanks.template" + + html_content=fields.Html('Html content') + type_id=fields.Many2one('opendons.type_donation_thanks_template', required=True) + product_id=fields.Many2one('product.product',domain="[('donation','=',True)]") + + +class opendons_type_donation_thanks_template(models.Model): + _name = 'opendons.type_donation_thanks_template' + _description = 'manage type donation thanks emplate' + + name=fields.Char('name') diff --git a/models/settings.py b/models/settings.py index 2e23890..ef069e9 100644 --- a/models/settings.py +++ b/models/settings.py @@ -7,6 +7,7 @@ class OpendonsSettings(models.TransientModel): generation_day=fields.Integer('Generation day in the month',config_parameter='opendons.generation_day') limit_days_before=fields.Integer('Limit days before generation day',config_parameter='opendons.limit_days_before') pa_debug_mode=fields.Boolean('Debug mode',config_parameter='opendons.pa_debug_mode') + donation_big_amount=fields.Integer('Donation big amount threshold',config_parameter='opendons.donation_big_amount') diff --git a/models/template_rf.py b/models/template_rf.py index c0f9e58..924b7ee 100644 --- a/models/template_rf.py +++ b/models/template_rf.py @@ -17,10 +17,17 @@ class opendons_template_rf(models.Model): description=fields.Text('description') active=fields.Boolean('active') html_content=fields.Html('Html content') + type_id=fields.Many2one('opendons.type_template_rf', required=True) def action_update_receipts(self): rf=self.env['donation.tax.receipt'].search([('template_rf_id','=',int(self.id))]) for r in rf: - r.html_content=self.html_content \ No newline at end of file + r.html_content=self.html_content + +class opendons_type_template_rf(models.Model): + _name = 'opendons.type_template_rf' + _description = 'manage type rf template' + + name=fields.Char('name') \ No newline at end of file diff --git a/report/report.xml b/report/report.xml index 21f2e65..8ce785f 100644 --- a/report/report.xml +++ b/report/report.xml @@ -1,6 +1,20 @@ + + Donation thanks report + donation.donation + qweb-pdf + opendons.report_donationthanks + opendons.report_donationthanks + 'Thanks-'+(object.number or '').replace('/','')+'.pdf' + + + report + + Donation Tax Receipt donation.tax.receipt diff --git a/report/report_donationtax.xml b/report/report_donationtax.xml index 29ab144..ece6da6 100644 --- a/report/report_donationtax.xml +++ b/report/report_donationtax.xml @@ -2,29 +2,23 @@ - + + +