Browse Source

RF

master
root 2 years ago
parent
commit
08e085c536
8 changed files with 54 additions and 12 deletions
  1. +1
    -0
      __manifest__.py
  2. +22
    -10
      models/donation_tax_receipt.py
  3. +1
    -0
      models/template_rf.py
  4. +1
    -1
      report/report.xml
  5. +2
    -1
      report/report_donationtax.xml
  6. +15
    -0
      report/report_templates.xml
  7. +11
    -0
      views/portal.xml
  8. +1
    -0
      views/template_rf.xml

+ 1
- 0
__manifest__.py View File

@ -47,6 +47,7 @@
'wizard/recurring_donation_wizard.xml', 'wizard/recurring_donation_wizard.xml',
'wizard/create_bank_deposit_wizard.xml', 'wizard/create_bank_deposit_wizard.xml',
'wizard/create_accounting_deposit_wizard.xml', 'wizard/create_accounting_deposit_wizard.xml',
'report/report_templates.xml',
'report/report_donationtax.xml', 'report/report_donationtax.xml',
'report/report_donation_recurring.xml', 'report/report_donation_recurring.xml',
'report/report.xml', 'report/report.xml',


+ 22
- 10
models/donation_tax_receipt.py View File

@ -1,12 +1,16 @@
from odoo import api, fields, models from odoo import api, fields, models
from datetime import datetime,timedelta,date from datetime import datetime,timedelta,date
import locale
import threading
from num2words import num2words
from contextlib import contextmanager
class DonationTaxReceipt(models.Model): class DonationTaxReceipt(models.Model):
_inherit = "donation.tax.receipt" _inherit = "donation.tax.receipt"
template_rf_id=fields.Many2one('opendons.template_rf', 'RF template') template_rf_id=fields.Many2one('opendons.template_rf', 'RF template')
html_content_print=fields.Html('html content print') html_content_print=fields.Html('html content print')
css_print=fields.Text('css')
pdf_file=fields.Binary("PDF") pdf_file=fields.Binary("PDF")
@ -16,18 +20,26 @@ class DonationTaxReceipt(models.Model):
res = super(DonationTaxReceipt, self).create(values) res = super(DonationTaxReceipt, self).create(values)
#generate the taxreceipt in HTMl format for PDF print #generate the taxreceipt in HTMl format for PDF print
template_rf=self.env['opendons.template_rf'].search([('type_rf','=','generic'),('active','=',True)],limit=1) template_rf=self.env['opendons.template_rf'].search([('type_rf','=','generic'),('active','=',True)],limit=1)
res.css_print=template_rf.css
html_content_print=template_rf.html_content html_content_print=template_rf.html_content
html_content_print=html_content_print.replace('{{partner_id.name}}',str(self.partner_id.name))
html_content_print=html_content_print.replace('{{partner_id.firstname}}',str(self.partner_id.firstname))
html_content_print=html_content_print.replace('{{adresse}}',str(self.update_adresse()))
html_content_print=html_content_print.replace('{{partner_id.name}}',str(res.partner_id.name))
html_content_print=html_content_print.replace('{{partner_id.firstname}}',str(res.partner_id.firstname))
html_content_print=html_content_print.replace('{{adresse}}',str(res.update_adresse()))
html_content_print=html_content_print.replace('{{number}}',str(res.number))
locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')
today=datetime.today()
html_content_print=html_content_print.replace('{{date}}',today.strftime("%d %B %Y"))
html_content_print=html_content_print.replace('{{donor_id}}',str(self.partner_id.donor_id)) html_content_print=html_content_print.replace('{{donor_id}}',str(self.partner_id.donor_id))
html_content_print=html_content_print.replace('{{fiscalyear}}',str(int(today.strftime("%Y"))-1))
html_content_print=html_content_print.replace('{{amount}}',str(res.amount))
html_content_print=html_content_print.replace('{{amountstr}}',num2words(float(res.amount),lang="fr",to="currency"))
res.html_content_print=html_content_print res.html_content_print=html_content_print
res.template_rf_id=template_rf.id res.template_rf_id=template_rf.id
return res return res
def get_portal_url(self): def get_portal_url(self):
return "/my/taxreceipt/print?id="+str(self.id) return "/my/taxreceipt/print?id="+str(self.id)
def action_print_rf(self): def action_print_rf(self):
@ -54,9 +66,9 @@ class DonationTaxReceipt(models.Model):
locality='<br>'+p.tax_locality if p.tax_locality else '' locality='<br>'+p.tax_locality if p.tax_locality else ''
zip=p.tax_zip if p.tax_zip else '' zip=p.tax_zip if p.tax_zip else ''
city=p.tax_city if p.tax_city 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>'
result='<p>'+title+' '+name+' '+firstname+'<br>'+street+street2+locality+'<br>'+zip+' '+city+'</p>'
else: else:
title=p.title.name if p.title.name else '' title=p.title.name if p.title.name else ''
name=p.name if p.name else '' name=p.name if p.name else ''
@ -66,9 +78,9 @@ class DonationTaxReceipt(models.Model):
locality='<br>'+p.locality if p.locality else '' locality='<br>'+p.locality if p.locality else ''
zip=p.zip if p.zip else '' zip=p.zip if p.zip else ''
city=p.city if p.city 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>'+title+' '+name+' '+firstname+'<br>'+street+street2+locality+'<br>'+zip+' '+city+'</p>'
#result="<p>Monsieur Dupont Marcel<br>7 avenue de la Marne</p><p>75016 Paris</p>" #result="<p>Monsieur Dupont Marcel<br>7 avenue de la Marne</p><p>75016 Paris</p>"
return result return result


+ 1
- 0
models/template_rf.py View File

@ -17,6 +17,7 @@ class opendons_template_rf(models.Model):
description=fields.Text('description') description=fields.Text('description')
active=fields.Boolean('active') active=fields.Boolean('active')
html_content=fields.Html('Html content') html_content=fields.Html('Html content')
css=fields.Text('css')
type_rf=fields.Selection(string='type',selection=[('generic','Generic'),('affectation','Affectation'),('high amount','High amount')]) type_rf=fields.Selection(string='type',selection=[('generic','Generic'),('affectation','Affectation'),('high amount','High amount')])

+ 1
- 1
report/report.xml View File

@ -23,7 +23,7 @@
<field name="report_file">opendons.report_donationtaxreceipt</field> <field name="report_file">opendons.report_donationtaxreceipt</field>
<field <field
name="print_report_name" name="print_report_name"
>'Fiscal_receipt-'+(object.number or '').replace('/','')+'.pdf'</field>
>'RF-'+(object.number or '').replace('/','')</field>
<field name="binding_model_id" ref="model_donation_tax_receipt" /> <field name="binding_model_id" ref="model_donation_tax_receipt" />
<field name="attachment_use" eval="True" /> <field name="attachment_use" eval="True" />
<field name="binding_type">report</field> <field name="binding_type">report</field>


+ 2
- 1
report/report_donationtax.xml View File

@ -8,7 +8,8 @@
<t t-call="web.html_container"> <t t-call="web.html_container">
<t t-call="web.internal_layout"> <t t-call="web.internal_layout">
<t t-foreach="docs" t-as="doc"> <t t-foreach="docs" t-as="doc">
<style t-esc="doc.css_print"/>
<div t-field="doc.html_content_print"/> <div t-field="doc.html_content_print"/>
<div style="page-break-after: always;" ></div> <div style="page-break-after: always;" ></div>


+ 15
- 0
report/report_templates.xml View File

@ -0,0 +1,15 @@
<odoo>
<template id="opendons_internal_layout" inherit_id="web.internal_layout">
<xpath expr="//div[@class='header']" position="replace">
<header>
</header>
</xpath>
</template>
</odoo>

+ 11
- 0
views/portal.xml View File

@ -82,4 +82,15 @@
</template> </template>
<template id="portal_kala_user_dropdown" name="kala user dropdown" inherit_id="portal.user_dropdown">
<xpath expr="//span[@t-if='_user_name']" position="replace">
<t t-if="user_id.partner_id.firstname">
<span t-attf-class="#{_user_name_class}" t-esc="user_id.partner_id.firstname"/>
</t>
<t t-if="not user_id.partner_id.firstname">
<span t-if="_user_name" t-attf-class="#{_user_name_class}" t-esc="user_id.name[:23] + '...' if user_id.name and len(user_id.name) &gt; 25 else user_id.name"/>
</t>
</xpath>
</template>
</odoo> </odoo>

+ 1
- 0
views/template_rf.xml View File

@ -16,6 +16,7 @@
<field name="type_rf"/> <field name="type_rf"/>
<field name="description"/> <field name="description"/>
<field name="active"/> <field name="active"/>
<field name="css"/>
<field name="html_content"/> <field name="html_content"/>
</group> </group>


Loading…
Cancel
Save