Skip to content

Commit

Permalink
Merge pull request #173 from CompassionCH/master
Browse files Browse the repository at this point in the history
Sponsorship Correspondence [Beneficiary to Supporter]
  • Loading branch information
ecino committed Feb 3, 2016
2 parents 3d39dbb + ee76097 commit 2fede8f
Show file tree
Hide file tree
Showing 303 changed files with 12,485 additions and 95 deletions.
14 changes: 12 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,21 @@ python:
- '2.7'

env:
- VERSION="8.0" ODOO_REPO="odoo/odoo" EXCLUDE="sbc_compassion"
global:
- VERSION="8.0"
- ODOO_REPO="odoo/odoo"
- EXCLUDE="sbc_compassion,onramp_compassion,label"
- OPENCV_ROOT=${HOME}/opencv
- ZXING_ROOT=${HOME}/.libZxing

virtualenv:
system_site_packages: true

install:
- travis/install_zxing.sh
- travis/install_opencv.sh
- export PYTHONPATH=${PYTHONPATH}:${OPENCV_ROOT}/install/lib/python2.7/site-packages
- python -c 'import cv2; print("OpenCV version is {}".format(cv2.__version__))'
- pip install flake8
- pip install pysftp
- pip install MySQL-python
Expand All @@ -26,6 +35,8 @@ install:
- pip install urllib3
- pip install certifi
- pip install coveralls
- pip install python-magic
- pip install wand
- git clone https://github.com/CompassionCH/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools -b r2
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- git clone https://github.com/OCA/l10n-switzerland.git ${HOME}/build/CompassionCH/l10n-switzerland -b 8.0
Expand All @@ -48,4 +59,3 @@ script:

after_success:
- coveralls

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Build Status](https://travis-ci.org/CompassionCH/compassion-modules.svg?branch=1.5-devel)](https://travis-ci.org/CompassionCH/compassion-modules)
[![Coverage Status](https://coveralls.io/repos/CompassionCH/compassion-modules/badge.svg)](https://coveralls.io/r/CompassionCH/compassion-modules)

[![Documentation](https://readthedocs.org/projects/compassion-modules/badge/?version=sbc-devel)](http://compassion-modules.readthedocs.org/en/sbc-devel/#sbc_compassion.tools.import_letter_functions)
Compassion modules
==================

Expand Down
8 changes: 6 additions & 2 deletions child_compassion/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

{
'name': 'Compassion Children',
'version': '1.4.1',
'version': '8.0.1',
'category': 'Other',
'author': 'Compassion CH',
'website': 'http://www.compassion.ch',
Expand All @@ -56,7 +56,11 @@
'data/delegate_child_compassion_cron.xml',
'data/child_compassion_template.xml',
],
'demo': [],
'demo': [
'demo/compassion.country.csv',
'demo/install.xml',
'demo/compassion.child.csv'
],
'installable': True,
'auto_install': False,
}
67 changes: 67 additions & 0 deletions child_compassion/demo/compassion.child.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
id,code,name
child_01,"BR2150576","Marilyn Monroe"
child_02,"RW3211095","Abraham Lincoln"
child_03,"PH2410150","Mother Teresa"
child_04,"IN2670004","John F. Kennedy"
child_05,"ET2110492","Martin Luther King"
child_06,"HA1463302","Nelson Mandela"
child_07,"IO1130185","Winston Churchill"
child_08,"HA1463748","Linus Torvald"
child_09,"KE3240344","Muhammad Ali"
child_10,"IO1130187","Mahatma Gandhi"
child_11,"IN2670005","Margaret Thatcher"
child_12,"IN2670008","Charles de Gaulle"
child_13,"IN2670013","Christopher Columbus"
child_14,"PH2410183","George Orwell"
child_15,"KE3240346","Charles Darwin"
child_16,"KE3240347","Elvis Presley"
child_17,"RW3211096","Albert Einstein"
child_18,"PE1130217","Isaac Newton"
child_19,"PE1130664","Paul McCartney"
child_20,"PE1130669","Plato"
child_21,"DR1611115","Queen Elizabeth"
child_22,"DR1611116","Queen Victoria"
child_23,"ET2110493","Mickhail Gorbachev"
child_24,"KE3240349","Jawaharlal Nehru"
child_25,"KE3240350","Leonardo da Vinci"
child_26,"ET2110494","Louis Pasteur"
child_27,"HA1463179","Leo Tolstoy"
child_28,"HA1463200","Pablo Picasso"
child_29,"TH2741031","Vincent Van Gogh"
child_30,"KE3240351","Franklin D. Roosevelt"
child_31,"TH2740802","Pope John Paul II"
child_32,"HA1463213","Thomas Edison"
child_33,"HA1463263","Rosa Parks"
child_34,"HA1463275","Aung San Suu Kyi"
child_35,"EC1200304","Lyndon Johnson"
child_36,"TH2741032","Ludwig Beethoven"
child_37,"HA1463277","Oprah Winfrey"
child_38,"RW3211097","Indira Gandhi"
child_39,"KE3240352","Eva Peron"
child_40,"KE3240353","Dalai Lama"
child_41,"BO3620066","Neil Armstrong"
child_42,"BO3350486","J. K. Rowling"
child_43,"TH2741033","Pele"
child_44,"HA1463289","John Lennon"
child_45,"KE3240361","Joseph Stalin"
child_46,"KE3240362","V. Lenin"
child_47,"HA1463301","Fidel Castro"
child_48,"RW3211098","Coco Chanel"
child_49,"IN2670014","Oscar Wilde"
child_50,"IN2670015","Sting"
child_51,"IN2670016","Alfred Hitchcock"
child_52,"KE3240364","Michael Jackson"
child_53,"PH2410184","Madonna"
child_54,"KE3240365","Cleopatra"
child_55,"KE3240367","Grace Kelly"
child_56,"IN2670022","Lionel Messi"
child_57,"PH2410185","Roger Federer"
child_58,"EI2000321","Sigmund Freud"
child_59,"RW3211099","Katherine Hepburn"
child_60,"PH2410190","Audrey Hepburn"
child_61,"ME7510018","David Beckham"
child_62,"IO1130189","Tiger Woods"
child_63,"KE3240368","Usain Bolt"
child_64,"KE3240369","Carl Lewis"
child_65,"DR1611114","C.S. Lewis"
child_66,"RW3211101","J. R. R. Tolkien"
15 changes: 15 additions & 0 deletions child_compassion/demo/compassion.country.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
id,iso_code
brazil,BR
rwanda,RW
philippines,PH
india,IN
ethiopia,ET
haiti,HT
indonesia,ID
kenya,KE
peru,PE
dominican_republic,DO
thailand,TH
ecuador,EC
bolivia,BO
mexico,MX
6 changes: 6 additions & 0 deletions child_compassion/demo/install.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate='1'>
<function model="compassion.country" name="_set_demo_data"/>
</data>
</openerp>
4 changes: 2 additions & 2 deletions child_compassion/model/child_compassion.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,8 @@ def _get_basic_informations(self):
'birthdate': json_data.get('birthDate') or False,
'gender': json_data.get('gender'),
'unique_id': json_data.get('childID'),
'completion_date': json_data.get('cdspCompletionDate')
or False,
'completion_date': json_data.get('cdspCompletionDate') or
False,
}
child.write(vals)
return True
Expand Down
7 changes: 7 additions & 0 deletions child_compassion/model/country_compassion.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,10 @@ def _get_url(self, api_mess, api_value):
url += ('/ci/v1/countries/' + api_mess + '/' + api_value +
'?api_key=' + api_key)
return url

@api.model
def _set_demo_data(self):
"""
Update the info of the demo countries
"""
self.search([]).update_informations()
4 changes: 2 additions & 2 deletions child_compassion/view/translated_values_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<openerp>
<data>
<!-- Top menu item -->
<menuitem id="menu_translated_value" parent="menu_sponsorship_root" name="Translated value" sequence="5"/>
<menuitem id="menu_configuration" parent="menu_sponsorship_root" name="Configuration" sequence="15"/>

<!--Compassion child form view -->
<record id="view_translated_value_tree" model="ir.ui.view">
Expand All @@ -28,7 +28,7 @@
</record>

<!--Compassion child form view -->
<menuitem id="menu_translated_value_translations" parent="menu_translated_value" name="Translations" action="open_view_translated_value_tree" sequence="0" />
<menuitem id="menu_configuration_translations" parent="menu_configuration" name="Translations" action="open_view_translated_value_tree" sequence="0" />

</data>
</openerp>
2 changes: 1 addition & 1 deletion contract_compassion/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

{
'name': 'Compassion Contracts',
'version': '1.5',
'version': '8.0.1',
'category': 'Other',
'author': 'Compassion CH',
'website': 'http://www.compassion.ch',
Expand Down
78 changes: 51 additions & 27 deletions contract_compassion/model/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class recurring_contract(models.Model):
'Partner Contract Number', required=True)
end_reason = fields.Selection('get_ending_reasons')
end_date = fields.Date(readonly=True, track_visibility='onchange')
months_paid = fields.Integer(
compute='_set_months_paid',
string='Months paid')
origin_id = fields.Many2one(
'recurring.contract.origin', 'Origin', ondelete='restrict',
track_visibility='onchange')
Expand All @@ -75,7 +78,8 @@ class recurring_contract(models.Model):
ondelete='restrict', track_visibility='onchange')
type = fields.Selection('_get_type', required=True)
group_freq = fields.Char(
'Frequency', compute='_set_frequency', store=True, readonly=True)
string='Payment frequency',
compute='_set_frequency', store=True, readonly=True)

##########################################################################
# FIELDS METHODS #
Expand Down Expand Up @@ -137,24 +141,60 @@ def _get_type(self):
return [('O', _('General'))]

@api.one
@api.depends('group_id.recurring_unit', 'group_id.recurring_value')
@api.depends('group_id.recurring_unit', 'group_id.recurring_value',
'group_id.advance_billing_months')
def _set_frequency(self):
recurring_value = 0
frequencies = {
'1 month': 'Monthly',
'2 month': 'Bimonthly',
'3 month': 'Quarterly',
'4 month': 'Four-monthly',
'6 month': 'Bi-annual',
'12 month': 'Annual',
'1 year': 'Annual',
'1 month': _('Monthly'),
'2 month': _('Bimonthly'),
'3 month': _('Quarterly'),
'4 month': _('Four-monthly'),
'6 month': _('Bi-annual'),
'12 month': _('Annual'),
'1 year': _('Annual'),
}
recurring_value = self.group_id.recurring_value
recurring_unit = self.group_id.recurring_unit
if self.type == 'S':
recurring_value = self.group_id.advance_billing_months
recurring_unit = 'month'
else:
recurring_value = self.group_id.recurring_value
recurring_unit = self.group_id.recurring_unit
frequency = "{0} {1}".format(recurring_value, recurring_unit)
if frequency in frequencies:
frequency = frequencies[frequency]
else:
frequency = 'Every ' + frequency + 's'
self.group_freq = frequency

@api.multi
def _set_months_paid(self):
"""This is a query returning the number of months paid for a
sponsorship."""
self._cr.execute(
"SELECT c.id as contract_id, "
"12 * (EXTRACT(year FROM next_invoice_date) - "
" EXTRACT(year FROM current_date))"
" + EXTRACT(month FROM c.next_invoice_date) - 1"
" - COALESCE(due.total, 0) as paidmonth "
"FROM recurring_contract c left join ("
# Open invoices to find how many months are due
" select contract_id, count(distinct invoice_id) as total "
" from account_invoice_line l join product_product p on "
" l.product_id = p.id "
" where state='open' and "
# Exclude gifts from count
" categ_name != 'Sponsor gifts'"
" group by contract_id"
") due on due.contract_id = c.id "
"WHERE c.id in (%s)" % ",".join([str(id) for id in self.ids])
)
res = self._cr.dictfetchall()
dict_contract_id_paidmonth = {
row['contract_id']: int(row['paidmonth']) for row in res}
for contract in self:
contract.months_paid = dict_contract_id_paidmonth[contract.id]

##########################################################################
# ORM METHODS #
##########################################################################
Expand Down Expand Up @@ -273,22 +313,6 @@ def on_change_group_id(self):
payment_term in ('LSV', 'Postfinance') and not is_active):
next_invoice_date = next_invoice_date + relativedelta(months=+1)
self.next_invoice_date = next_invoice_date.strftime(DF)

@api.multi
def open_contract(self):
""" Used to bypass opening a contract in popup mode from
res_partner view. """
self.ensure_one()
return {
'type': 'ir.actions.act_window',
'name': 'Contract',
'view_type': 'form',
'view_mode': 'form',
'res_model': self._name,
'res_id': self.id,
'target': 'current',
'context': self.with_context(default_type=self.type).env.context
}

##########################################################################
# WORKFLOW METHODS #
Expand Down
2 changes: 1 addition & 1 deletion contract_compassion/tests/test_contract_compassion.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_contract_compassion_first_scenario(self):
"""
In this test we are testing states changement of a contract and if
the old invoice are well cancelled when we pay one invoice.
"""
"""
contract_group = self._create_group(
'do_nothing', self.partners.ids[0], 5,
self.payment_term_id,
Expand Down
2 changes: 1 addition & 1 deletion contract_compassion/view/contract_origin_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
</record>

<menuitem id="menu_sponsorship_origin" parent="child_compassion.menu_sponsorship_section"
name="Origins" groups="child_compassion.group_sponsorship" sequence="4"
name="Origins" groups="child_compassion.group_sponsorship" sequence="6"
action="open_view_origin_tree"/>
</data>
</openerp>
13 changes: 8 additions & 5 deletions contract_compassion/view/contract_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
<field name="partner_codega" invisible="context.get('partner_contracts_view')" />
</field>
<field name="payment_term_id" position="after">
<field name="group_freq" />
<field name="origin_id" />
</field>
<field name="state" position="after">
<button name="open_contract" type="object" invisible="not context.get('partner_contracts_view')" icon="STOCK_JUMP_TO" />
<field name="group_freq" invisible="not context.get('partner_contracts_view')"/>
<field name="last_paid_invoice_date" invisible="not context.get('partner_contracts_view')"/>
<field name="months_paid" invisible="not context.get('partner_contracts_view')"/>
</field>
<field name="reference" position="replace" />
</data>
Expand Down Expand Up @@ -87,6 +85,11 @@
<field name="end_reason" states="terminated,cancelled"/>
<field name="num_pol_ga" invisible="1"/>
</group>
<group>
<field name="group_freq"/>
<field name="months_paid"/>
<field name="last_paid_invoice_date"/>
</group>
</group>
</xpath>
</field>
Expand Down
2 changes: 1 addition & 1 deletion crm_compassion/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

{
'name': 'Compassion CH - Events',
'version': '1.4.1',
'version': '8.0.1',
'category': 'CRM',
'sequence': 150,
'author': 'Compassion CH',
Expand Down
4 changes: 2 additions & 2 deletions crm_compassion/view/contract_origin_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@
<field eval="18" name="priority"/>
<field name="arch" type="xml">
<data>
<field name="origin_id" position="after">
<field name="user_id" />
<field name="group_freq" position="after">
<field name="user_id" invisible="context.get('partner_contracts_view')"/>
</field>
</data>
</field>
Expand Down
Loading

0 comments on commit 2fede8f

Please sign in to comment.