Browse Source

espace donateur

master
root 3 years ago
parent
commit
f58d768f4b
9 changed files with 263 additions and 14 deletions
  1. +1
    -0
      __manifest__.py
  2. +2
    -1
      controllers/__init__.py
  3. +135
    -0
      controllers/portal.py
  4. +1
    -1
      i18n/fr.po
  5. +7
    -2
      models/donation.py
  6. +9
    -1
      models/donation_tax_receipt.py
  7. +85
    -0
      views/portal.xml
  8. +11
    -9
      views/recurring_donation.xml
  9. +12
    -0
      views/template_rf.xml

+ 1
- 0
__manifest__.py View File

@ -53,6 +53,7 @@
'views/donation_tax_receipt.xml', 'views/donation_tax_receipt.xml',
'views/laposte_ref.xml', 'views/laposte_ref.xml',
'views/partner_import.xml', 'views/partner_import.xml',
'views/portal.xml',
'data/donation_recurring_mail_template.xml' 'data/donation_recurring_mail_template.xml'
#'views/website_donation.xml' #'views/website_donation.xml'


+ 2
- 1
controllers/__init__.py View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from . import controllers from . import controllers
from . import donation
from . import donation
from . import portal

+ 135
- 0
controllers/portal.py View File

@ -0,0 +1,135 @@
from odoo import http,_
from odoo.http import request
import werkzeug
from odoo.exceptions import UserError
from odoo.addons.portal.controllers.portal import CustomerPortal,pager as portal_pager, get_records_pager
class PortalOpendons(CustomerPortal):
def _prepare_home_portal_values(self, counters):
values = super()._prepare_home_portal_values(counters)
partner = request.env.user.partner_id
if 'taxreceipt_count' in counters:
taxreceipt_count=request.env['donation.tax.receipt'].search_count([('partner_id','=',int(partner.id))])
values['taxreceipt_count'] = taxreceipt_count
if 'donation_count' in counters:
donation_count=request.env['donation.donation'].search_count(['&',('partner_id','=',int(partner.id)),('state','=','done')])
values['donation_count'] = donation_count
return values
@http.route(['/my/taxreceipts', '/my/taxreceipts/page/<int:page>'], type='http', auth="user", website=True)
def portal_my_taxreceipts(self, page=1, date_begin=None, date_end=None, sortby=None, **kw):
values = self._prepare_portal_layout_values()
partner = request.env.user.partner_id
taxreceipt = request.env['donation.tax.receipt']
domain = [
('partner_id', '=',int(partner.id) )
]
searchbar_sortings = {
'date': {'label': _('Tax receipt Date'), 'taxreceipt': 'date desc'},
}
# default sortby order
if not sortby:
sortby = 'date'
sort_taxreceipt = searchbar_sortings[sortby]['taxreceipt']
if date_begin and date_end:
domain += [('create_date', '>', date_begin), ('create_date', '<=', date_end)]
# count for pager
taxreceipt_count = taxreceipt.search_count(domain)
# make pager
pager = portal_pager(
url="/my/taxreceipts",
url_args={'date_begin': date_begin, 'date_end': date_end, 'sortby': sortby},
total=taxreceipt_count,
page=page,
step=self._items_per_page
)
# search the count to display, according to the pager data
taxreceipts = taxreceipt.search(domain, order=sort_taxreceipt, limit=self._items_per_page, offset=pager['offset'])
request.session['my_taxreceipt_history'] = taxreceipts.ids[:100]
values.update({
'date': date_begin,
'taxreceipts': taxreceipts.sudo(),
'page_name': 'tax receipts',
'pager': pager,
'default_url': '/my/taxreceipts',
'searchbar_sortings': searchbar_sortings,
'sortby': sortby,
})
return request.render("opendons.portal_my_taxreceipts", values)
@http.route(['/my/donations', '/my/donations/page/<int:page>'], type='http', auth="user", website=True)
def portal_my_donations(self, page=1, date_begin=None, date_end=None, sortby=None, **kw):
values = self._prepare_portal_layout_values()
partner = request.env.user.partner_id
donation = request.env['donation.line']
domain = [
('partner_id', '=',int(partner.id) )
]
searchbar_sortings = {
'date': {'label': _('Donation Date'), 'Donation': 'donation_date desc'},
}
# default sortby order
if not sortby:
sortby = 'date'
sort_donation = searchbar_sortings[sortby]['Donation']
if date_begin and date_end:
domain += [('create_date', '>', date_begin), ('create_date', '<=', date_end)]
# count for pager
donation_count = donation.search_count(domain)
# make pager
pager = portal_pager(
url="/my/donations",
url_args={'date_begin': date_begin, 'date_end': date_end, 'sortby': sortby},
total=donation_count,
page=page,
step=self._items_per_page
)
# search the count to display, according to the pager data
donations = donation.search(domain, order=sort_donation, limit=self._items_per_page, offset=pager['offset'])
request.session['my_donation_history'] = donations.ids[:100]
values.update({
'date': date_begin,
'donations': donations.sudo(),
'page_name': 'Donations',
'pager': pager,
'default_url': '/my/donations',
'searchbar_sortings': searchbar_sortings,
'sortby': sortby,
})
return request.render("opendons.portal_my_donations", values)
@http.route('/my/taxreceipt/print', methods=['POST', 'GET'], csrf=False, type='http', auth="user", website=True)
def print_id(self, **kw):
tr=request.env['donation.tax.receipt'].sudo().search([('id','=',int(kw['id']))])
if tr:
#mise à jour du champ htl à imprimer
tr.update_print_pdf()
pdf = request.env.ref('opendons.report_donation_tax_receipt').sudo()._render_qweb_pdf([tr.id])[0]
pdfhttpheaders = [('Content-Type', 'application/pdf'), ('Content-Length', len(pdf))]
return request.make_response(pdf, headers=pdfhttpheaders)
else:
return request.redirect('/')

+ 1
- 1
i18n/fr.po View File

@ -1210,7 +1210,7 @@ msgstr ""
#: model:ir.actions.act_window,name:opendons.template_rf_action #: model:ir.actions.act_window,name:opendons.template_rf_action
#: model:ir.ui.menu,name:opendons.opendons_template_rf #: model:ir.ui.menu,name:opendons.opendons_template_rf
msgid "Receipts letters Templates " msgid "Receipts letters Templates "
msgstr "Modèle de lettres de reçu"
msgstr "Modèle de lettres de reçu fiscal"
#. module: opendons #. module: opendons
#: model:ir.actions.act_window,name:opendons.donation_recurring_action #: model:ir.actions.act_window,name:opendons.donation_recurring_action


+ 7
- 2
models/donation.py View File

@ -47,7 +47,6 @@ class DonationDonation(models.Model):
start_date= fields.Date( start_date= fields.Date(
string='Start Date', string='Start Date',
index=True, index=True,
required=True,
track_visibility='onchange' track_visibility='onchange'
) )
end_date = fields.Date( end_date = fields.Date(
@ -620,4 +619,10 @@ class DonationDonation(models.Model):
else: else:
name = super(DonationDonation, donation).name_get()[0][1] name = super(DonationDonation, donation).name_get()[0][1]
res.append((donation.id, name)) res.append((donation.id, name))
return res
return res
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')

+ 9
- 1
models/donation_tax_receipt.py View File

@ -8,6 +8,8 @@ class DonationTaxReceipt(models.Model):
html_content=fields.Html('html content',compute='_html_content_rf') html_content=fields.Html('html content',compute='_html_content_rf')
html_content_print=fields.Html('html content print') html_content_print=fields.Html('html content print')
def get_portal_url(self):
return "my/taxreceipt/print?id="+str(self.id)
def action_print_rf(self): def action_print_rf(self):
self.ensure_one() self.ensure_one()
@ -23,4 +25,10 @@ class DonationTaxReceipt(models.Model):
#return True #return True
def _html_content_rf(self): def _html_content_rf(self):
self.html_content=self.template_rf_id.html_content
self.html_content=self.template_rf_id.html_content
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

+ 85
- 0
views/portal.xml View File

@ -0,0 +1,85 @@
<odoo>
<template id="portal_my_home_taxreceipt" name="Tax receipts" inherit_id="portal.portal_my_home" customize_show="True" priority="30">
<xpath expr="//div[hasclass('o_portal_docs')]" position="inside">
<t t-call="portal.portal_docs_entry">
<t t-set="title">Tax receipts</t>
<t t-set="url" t-value="'/my/taxreceipts'"/>
<t t-set="placeholder_count" t-value="'taxreceipt_count'"/>
</t>
</xpath>
</template>
<template id="portal_my_home_donation" name="Tax receipts" inherit_id="portal.portal_my_home" customize_show="True" priority="30">
<xpath expr="//div[hasclass('o_portal_docs')]" position="inside">
<t t-call="portal.portal_docs_entry">
<t t-set="title">Donations</t>
<t t-set="url" t-value="'/my/donations'"/>
<t t-set="placeholder_count" t-value="'donation_count'"/>
</t>
</xpath>
</template>
<template id="portal_my_taxreceipts" name="My Tax receipts">
<t t-call="portal.portal_layout">
<t t-set="breadcrumbs_searchbar" t-value="True"/>
<t t-call="portal.portal_searchbar">
<t t-set="title">Tax receipts</t>
</t>
<t t-if="not taxreceipts">
<p>There are currently no tax receipts for your account.</p>
</t>
<t t-if="taxreceipts" t-call="portal.portal_table">
<thead>
<tr class="active">
<th>tax receipt #</th>
<th class="text-right">Date</th>
<th class="text-right">Total</th>
</tr>
</thead>
<t t-foreach="taxreceipts" t-as="taxr">
<tr>
<td><a t-att-href="taxr.get_portal_url()"><t t-esc="taxr.number"/></a></td>
<td class="text-right"><span t-field="taxr.date"/></td>
<td class="text-right"><span t-field="taxr.amount"/></td>
</tr>
</t>
</t>
</t>
</template>
<template id="portal_my_donations" name="My Donations">
<t t-call="portal.portal_layout">
<t t-set="breadcrumbs_searchbar" t-value="True"/>
<t t-call="portal.portal_searchbar">
<t t-set="title">Donations</t>
</t>
<t t-if="not donations">
<p>There are currently no donation for your account.</p>
</t>
<t t-if="donations" t-call="portal.portal_table">
<thead>
<tr class="active">
<th class="text-left">Date</th>
<th class="text-center">Affectation</th>
<th class="text-right">Amount</th>
</tr>
</thead>
<t t-foreach="donations" t-as="donation">
<tr>
<td class="text-left"><span t-field="donation.donation_date"/></td>
<td class="text-center"><span t-field="donation.product_id.name"/></td>
<td class="text-right"><span t-field="donation.amount"/></td>
</tr>
</t>
</t>
</t>
</template>
</odoo>

+ 11
- 9
views/recurring_donation.xml View File

@ -9,7 +9,7 @@
<xpath expr="//field[@name='donation_date']" position="replace"> <xpath expr="//field[@name='donation_date']" position="replace">
<field name="donation_date" string="date" attrs="{'readonly':[('recurring_template','=','stopped')]}"/> <field name="donation_date" string="date" attrs="{'readonly':[('recurring_template','=','stopped')]}"/>
<field name="start_date" string="start date" attrs="{'readonly':[('recurring_template','=','stopped')]}"/>
<field name="start_date" string="start date" attrs="{'invisible':[('recurring_template','=',False)],'required':[('recurring_template','=',True)],'readonly':[('recurring_template','=','stopped')]}"/>
<field name="lastexecution_date" t-options='{"format": "dd / MM / yyyy HH / mm"}' attrs="{'invisible':[('recurring_template','not in',('active','suspended','stopped'))]}"/> <field name="lastexecution_date" t-options='{"format": "dd / MM / yyyy HH / mm"}' attrs="{'invisible':[('recurring_template','not in',('active','suspended','stopped'))]}"/>
<field name="suspended_date" attrs="{'invisible':[('recurring_template','not in',('active','suspended','stopped'))]}"/> <field name="suspended_date" attrs="{'invisible':[('recurring_template','not in',('active','suspended','stopped'))]}"/>
<field name="end_date" attrs="{'readonly':[('recurring_template','=','stopped')],'invisible':[('recurring_template','not in',('active','suspended','stopped'))]}"/> <field name="end_date" attrs="{'readonly':[('recurring_template','=','stopped')],'invisible':[('recurring_template','not in',('active','suspended','stopped'))]}"/>
@ -30,19 +30,21 @@
</xpath> --> </xpath> -->
<!-- <xpath expr="//field[@name='thanks_template_id']" position="replace">
<field name="template_pa_id"/>
<field name="html_content"/>
</xpath> -->
<xpath expr="//field[@name='thanks_template_id']" position="replace">
<field name="thanks_template_id" attrs="{'invisible':[('recurring_template','!=','')]}" widget="selection" />
</xpath>
<xpath expr="//field[@name='thanks_printed']" position="replace"> <xpath expr="//field[@name='thanks_printed']" position="replace">
<field name="thanks_printed" attrs="{'readonly':[('recurring_template','=','stopped')]}"/>
<field name="thanks_printed" attrs="{'readonly':[('recurring_template','=','stopped')],'invisible':[('recurring_template','!=','')]}"/>
</xpath> </xpath>
<xpath expr="//field[@name='line_ids']" position="replace"> <xpath expr="//field[@name='line_ids']" position="replace">
<field name="line_ids" attrs="{'readonly':[('recurring_template','=','stopped')]}" nolabel="1"/> <field name="line_ids" attrs="{'readonly':[('recurring_template','=','stopped')]}" nolabel="1"/>
</xpath> </xpath>
<xpath expr="//field[@name='tax_receipt_id']" position="replace">
<field name="tax_receipt_id" attrs="{'invisible':[('recurring_template','!=','')]}" />
</xpath>
<xpath expr="//field[@name='campaign_id']" position="replace"> <xpath expr="//field[@name='campaign_id']" position="replace">
</xpath> </xpath>
@ -140,11 +142,11 @@
<field name="frequency" invisible="not context.get('recurring_view')"/> <field name="frequency" invisible="not context.get('recurring_view')"/>
</xpath> </xpath>
<xpath expr="//field[@name='frequency']" position="after">
<!-- <xpath expr="//field[@name='frequency']" position="after">
<field name="start_date" invisible="not context.get('recurring_view')"/> <field name="start_date" invisible="not context.get('recurring_view')"/>
<field name="lastexecution_date" invisible="not context.get('recurring_view')"/> <field name="lastexecution_date" invisible="not context.get('recurring_view')"/>
</xpath>
</xpath> -->
@ -175,7 +177,7 @@
<page name="lines" position="after"> <page name="lines" position="after">
<page <page
name="recurring_print_mail_history" name="recurring_print_mail_history"
string="recurring print mail history"
string="Communication history"
attrs="{'invisible': [('recurring_template', '=', False)]}" attrs="{'invisible': [('recurring_template', '=', False)]}"
> >
<field name="print_email_history_ids" nolabel="1"> <field name="print_email_history_ids" nolabel="1">


+ 12
- 0
views/template_rf.xml View File

@ -25,6 +25,18 @@
</field> </field>
</record> </record>
<record model="ir.ui.view" id="opendons.template_rf_list" >
<field name="name">opendons_template_rf List</field>
<field name="model">opendons.template_rf</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="active"/>
<field name="description"/>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="template_rf_action"> <record model="ir.actions.act_window" id="template_rf_action">


Loading…
Cancel
Save