Browse Source

thanks letter et RF

master
root 3 years ago
parent
commit
cd588fcb12
17 changed files with 269 additions and 24 deletions
  1. +4
    -0
      __manifest__.py
  2. +25
    -0
      data/data.xml
  3. +2
    -2
      i18n/fr.po
  4. +1
    -0
      models/__init__.py
  5. +21
    -1
      models/donation.py
  6. +86
    -1
      models/donation_tax_receipt.py
  7. +16
    -0
      models/donation_thanks_template.py
  8. +1
    -0
      models/settings.py
  9. +8
    -1
      models/template_rf.py
  10. +14
    -0
      report/report.xml
  11. +9
    -15
      report/report_donationtax.xml
  12. +27
    -0
      report/report_donationthanks.xml
  13. +2
    -0
      security/ir.model.access.csv
  14. +40
    -0
      views/donation_thanks_template.xml
  15. +4
    -4
      views/recurring_donation.xml
  16. +7
    -0
      views/settings.xml
  17. +2
    -0
      views/template_rf.xml

+ 4
- 0
__manifest__.py View File

@ -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'


+ 25
- 0
data/data.xml View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="opendons_type_template_rf1" model="opendons.type_template_rf">
<field name="name">generic</field>
</record>
<record id="opendons_type_template_rf2" model="opendons.type_template_rf">
<field name="name">affectation</field>
</record>
<record id="opendons_type_template_rf3" model="opendons.type_template_rf">
<field name="name">high amount</field>
</record>
<record id="opendons_type_donation_thanks_template1" model="opendons.type_donation_thanks_template">
<field name="name">generic</field>
</record>
<record id="opendons_type_donation_thanks_template2" model="opendons.type_donation_thanks_template">
<field name="name">affectation</field>
</record>
<record id="opendons_type_donation_thanks_template3" model="opendons.type_donation_thanks_template">
<field name="name">high amount</field>
</record>
</odoo>

+ 2
- 2
i18n/fr.po View File

@ -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


+ 1
- 0
models/__init__.py View File

@ -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

+ 21
- 1
models/donation.py View File

@ -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')
partner_id=fields.Many2one(related='donation_id.partner_id')

+ 86
- 1
models/donation_tax_receipt.py View File

@ -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
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='<br>'+p.tax_street2 if p.tax_street2 else ''
locality='<br>'+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='<p>'+title+' '+name+' '+firstname+'<br>'+street+street2+locality+'<br>'+zip+' '+city+'<br>'+country+'</p>'
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='<br>'+p.street2 if p.street2 else ''
locality='<br>'+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='<p>'+title+' '+name+' '+firstname+'<br>'+street+street2+locality+'<br>'+zip+' '+city+'<br>'+country+'</p>'
#result="<p>Monsieur Dupont Marcel<br>7 avenue de la Marne</p><p>75016 Paris</p>"
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)

+ 16
- 0
models/donation_thanks_template.py View File

@ -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')

+ 1
- 0
models/settings.py View File

@ -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')


+ 8
- 1
models/template_rf.py View File

@ -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
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')

+ 14
- 0
report/report.xml View File

@ -1,6 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="report_donation_thanks" model="ir.actions.report">
<field name="name">Donation thanks report </field>
<field name="model">donation.donation</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">opendons.report_donationthanks</field>
<field name="report_file">opendons.report_donationthanks</field>
<field
name="print_report_name"
>'Thanks-'+(object.number or '').replace('/','')+'.pdf'</field>
<field name="binding_model_id" ref="model_donation_tax_receipt" />
<field name="attachment_use" eval="True" />
<field name="binding_type">report</field>
</record>
<record id="report_donation_tax_receipt" model="ir.actions.report">
<field name="name">Donation Tax Receipt</field>
<field name="model">donation.tax.receipt</field>


+ 9
- 15
report/report_donationtax.xml View File

@ -2,29 +2,23 @@
<odoo>
<template id="opendons.report_donationtaxreceipt_document">
<t t-foreach="docs" t-as="o">
<t t-call="web.internal_layout">
<div t-field="o.html_content_print"/>
</t>
</t>
</template>
<template id="report_donationtaxreceipt">
<t t-call="web.html_container">
<t t-call="web.internal_layout">
<t t-foreach="docs" t-as="doc">
<t
t-call="opendons.report_donationtaxreceipt_document"
t-lang="doc.partner_id.lang"
/>
<div t-field="doc.html_content_print"/>
<div style="page-break-after: always;" ></div>
</t>
</t>
</t>
</template>
<template id="opendons_template_donation_tax_receipt" inherit_id="donation_base.report_donationtaxreceipt_document">
<xpath expr="//div[@class='page']" position="replace">


+ 27
- 0
report/report_donationthanks.xml View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="opendons.report_donationthanks_document">
<t t-foreach="docs" t-as="o">
<t t-call="web.internal_layout">
<div t-field="o.html_content_print"/>
</t>
</t>
</template>
<template id="report_donationthanks">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="doc">
<t
t-call="opendons.report_donationthanks_document"
t-lang="doc.partner_id.lang"
/>
</t>
</t>
</template>
</odoo>

+ 2
- 0
security/ir.model.access.csv View File

@ -32,6 +32,8 @@ 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_donation_thanks_type_template,opendons_donation_thanks_type_template,model_opendons_type_donation_thanks_template,donation.group_donation_manager,1,1,1,1
access_opendons_laposte_ref,opendons_laposte_ref,model_opendons_laposte_ref,donation.group_donation_manager,1,1,1,1


+ 40
- 0
views/donation_thanks_template.xml View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="donation_thanks_template_form" model="ir.ui.view">
<field name="name">opendons.donation.form</field>
<field name="model">donation.thanks.template</field>
<field name="inherit_id" ref="donation.donation_thanks_template_form" />
<field name="arch" type="xml">
<xpath expr="//group[@name='main']" position="replace">
<group name="main">
<field name="active" invisible="1" />
<field name="name" />
<field name="type_id" />
<field name="product_id" />
<field name="html_content" />
<field name="company_id" groups="base.group_multi_company" />
</group>
</xpath>
</field>
</record>
<record id="donation_thanks_template_tree" model="ir.ui.view">
<field name="name">opendons.donation.form</field>
<field name="model">donation.thanks.template</field>
<field name="inherit_id" ref="donation.donation_thanks_template_tree" />
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="after">
<field name="type_id" />
</xpath>
</field>
</record>
</odoo>

+ 4
- 4
views/recurring_donation.xml View File

@ -31,11 +31,11 @@
<xpath expr="//field[@name='thanks_template_id']" position="replace">
<field name="thanks_template_id" attrs="{'invisible':[('recurring_template','!=','')]}" widget="selection" />
<field name="thanks_template_id" attrs="{'invisible':[('recurring_template','!=',False)]}" widget="selection" />
</xpath>
<xpath expr="//field[@name='thanks_printed']" position="replace">
<field name="thanks_printed" attrs="{'readonly':[('recurring_template','=','stopped')],'invisible':[('recurring_template','!=','')]}"/>
<field name="thanks_printed" attrs="{'readonly':[('recurring_template','=','stopped')],'invisible':[('recurring_template','!=',False)]}"/>
</xpath>
<xpath expr="//field[@name='line_ids']" position="replace">
@ -84,8 +84,8 @@
</xpath>
<xpath expr="//button[@name='active2suspended']" position="after">
<button name="show_print_wizard" type="object" string="Print"/>
<button name="action_send_pa" type="object" string="Email"/>
<button name="show_print_wizard" attrs="{'invisible': [('recurring_template', '=', False)]}" type="object" string="Print"/>
<button name="action_send_pa" attrs="{'invisible': [('recurring_template', '=', False)]}" type="object" string="Email"/>
</xpath>


+ 7
- 0
views/settings.xml View File

@ -7,6 +7,13 @@
<field name="arch" type="xml">
<xpath expr="//div[hasclass('settings')]" position="inside">
<div class="app_settings_block" data-string="Opendon" data-key="opendons">
<h2>Tax receipt</h2>
<div class="row mt16 o_settings_container">
<div class="o_setting_left_pane">
<label for="donation_big_amount" class="o_light_label"/>
<field name="donation_big_amount"/>
</div>
</div>
<h2>Recurring payment management</h2>
<div class="row mt16 o_settings_container">
<div class="o_setting_left_pane">


+ 2
- 0
views/template_rf.xml View File

@ -13,6 +13,7 @@
<sheet>
<group name="main">
<field name="name"/>
<field name="type_id"/>
<field name="description"/>
<field name="active"/>
<field name="html_content"/>
@ -32,6 +33,7 @@
<tree>
<field name="name"/>
<field name="active"/>
<field name="type_id"/>
<field name="description"/>
</tree>


Loading…
Cancel
Save