Compare commits

...

129 Commits

Author SHA1 Message Date
Manuel Claeys Bouuaert b7279658bb fixup! [FIX] tax_shelter_declaration: enable exclusion to deal with overlapping declarations 4 years ago
Manuel Claeys Bouuaert 08b74ed41b [FIX] tax_shelter_declaration: enable exclusion to deal with overlapping declarations 4 years ago
houssine 428f99f1eb [FIX] remove cooperator duplicate field 5 years ago
houssine 13abea861a [VER] update version 5 years ago
Houssine BAKKALI 3c1676a733
Merge pull request #95 from coopiteasy/9.0-touch_cooperator_type 5 years ago
houssine ee4e1c0858 [IMP] add button to allow to update cooperator type without sql. 5 years ago
Houssine BAKKALI c972d23d7a
Merge pull request #86 from coopiteasy/9.0-fix-company-form-fill-values 5 years ago
Houssine BAKKALI 7d62c32a6a
Merge pull request #89 from coopiteasy/9.0-fix-when-parner-existing 5 years ago
houssine 6010973c21 [IMP] add constraint email and company email must be different 5 years ago
houssine 3957e2ee46 [IMP] make fields mandatory 5 years ago
houssine 4a3d2e6c6b [FIX] when partner was already in the database. 5 years ago
houssine 9a223b6ba8 [IMP] display field for group system 5 years ago
houssine d6f4434546 [FIX] add calls to fill_values and update values on error 5 years ago
Manuel Claeys Bouuaert 0173332902
Merge pull request #79 from coopiteasy/9.0-emc-fix-transfer-pp-pm 5 years ago
Manuel Claeys Bouuaert b6bee7d98c fixup! [FIX] emc: check share to_company and to_individual on transfer 5 years ago
Manuel Claeys Bouuaert 23f81942fe [FIX] emc: check share to_company and to_individual on transfer 5 years ago
houssine 9ed04d95f7 [FIXME] add fixme message 5 years ago
Elouan Le Bars c18c5e32b0 [ADD] emc: add worker/eater demo datas 5 years ago
Elouan Le Bars 64025325f6 [ADD] emc: share_product default_code to demo datas 5 years ago
Elouan Le Bars eb52fc6f83 [ADD] emc: demo datas 5 years ago
Elouan Le Bars 0d09965a69 [FIX] emc: cooperator computation issue 5 years ago
Houssine BAKKALI 6812d83e02
Merge pull request #60 from coopiteasy/9.0-check-contact-company-emails 5 years ago
Manuel Claeys Bouuaert c974a1a04e fixup! fixup! [ADD] add date of generation on certificate, smaller signature and font-size to prevent 2nd page 5 years ago
Manuel Claeys Bouuaert 93eeff3a73 fixup! [ADD] add date of generation on certificate, smaller signature and font-size to prevent 2nd page 5 years ago
Elouan Le Bars 1cfd58251c [ADD] emc : company and contact emails must be different 5 years ago
Manuel Claeys Bouuaert 2c2bd12765 [ADD] add date of generation on certificate, smaller signature and font-size to prevent 2nd page 5 years ago
houssine 28977951ad [FIX] sometime product template and product product diverge. 5 years ago
Houssine BAKKALI 29fec9d5ec
Merge pull request #54 from coopiteasy/9.0-fix-flag-cooperator 5 years ago
houssine 6d9fc8fa95 [FIX] fix uncovered use case 5 years ago
Elouan Le Bars 95da099322 [ADD] emc : email when added to waiting list 5 years ago
Rémy Taymans e053dff6d2 [FIX] emc: One route to rule them all 5 years ago
Rémy Taymans f056eb1b2a [PEP] easy_my_coop main controller 5 years ago
Rémy Taymans e87c7b9e9a [CHG] emc: Hide fields in become_cooperator when user is logged 5 years ago
Elouan Le Bars f406155d5c [FIX] Mandatory field not displayed 5 years ago
Robin Keunen b89635c2b3
Merge pull request #17 from coopiteasy/9.0-fix-install-from-scratch 5 years ago
Elouan Le Bars ac153d748a [IMP] Change approval order for internal rules, data policy and financial risk 5 years ago
Houssine BAKKALI 59a53a7c7a
Merge pull request #22 from coopiteasy/9.0-unrequire-some-fields-when-logged 5 years ago
Houssine BAKKALI e6d669c154
[PEP8] remove unused import 5 years ago
houssine 6e50f34afd [FIX] fix by pass control when iban not given 5 years ago
houssine 8a631f53ed [IMP] put website of CIE 5 years ago
houssine 6481ef3952 [IMP] make some fields non required when logged 5 years ago
Elouan Le Bars 88595b542f [FIX] internal rules checkbox required attribute 5 years ago
Elouan Le Bars 7cf099fec4 [ADD] Financial risk approval on subscription 5 years ago
houssine b70b4f558a [IMP] replace multi by model as we don't work with self 5 years ago
houssine d6c46f6c0e [IMP] get email template from its xml id instead of searching the name 5 years ago
houssine 96bc0e7b58 [FIX] move root menus in a dedicated file to load first 5 years ago
houssine bb4b2ebcb7 [FIX] fix t-att attributes for data policy 5 years ago
houssine c8881872e6 Merge branch '9.0' of https://github.com/coopiteasy/vertical-cooperative.git into 9.0 5 years ago
houssine 1b39e78ce1 [IMP] class name in camel case 5 years ago
Houssine BAKKALI 4ddc8aa933
Merge pull request #18 from coopiteasy/9.0_fix_confirmation_email 5 years ago
houssine 8078b6cedc [IMP] set default_code required when is_share is True 5 years ago
houssine 2a2744dd6b [FIX] fix mix share if statement 5 years ago
houssine 3308dbc4c7 [FIX] fix email confirmation read only when logged. 5 years ago
robin.keunen 54da114669 [IMP] emc: remove cooperative_history_wizard 5 years ago
houssine a412c17042 [FIX] remove duplicate instruction 5 years ago
robin.keunen 31b8b2d8d7 [FIX] easy_my_coop: reorder menu definitions 5 years ago
houssine 373848789b [FIX] fix expected singleton 5 years ago
houssine 1ab411a4de [FIX] fix filter 5 years ago
houssine fc51d8a7ee [FIX] fix again 5 years ago
houssine a722834c45 [FIX] fix filtering expression 5 years ago
Houssine BAKKALI 69744b14c0
Merge pull request #14 from coopiteasy/9.0_add_option_to_wizard 5 years ago
houssine 5af8b99977 [IMP] add filter on sub requests 5 years ago
Houssine BAKKALI 693dc20246
Merge pull request #13 from coopiteasy/9.0_add_option_to_wizard 5 years ago
houssine 36df37fb77 Merge branch '9.0_add_option_to_wizard' of https://github.com/coopiteasy/vertical-cooperative.git into 9.0_add_option_to_wizard 5 years ago
Houssine BAKKALI 3dff9cf9e1 Update update_partner_info.py 5 years ago
Houssine BAKKALI 5934284cff
Update update_partner_info.py 5 years ago
Houssine BAKKALI c62fbfcbe1
Merge pull request #8 from coopiteasy/9-translation-fr-easy-my-coop 5 years ago
houssine d10e1d711c [IMP] option to update birthdate from subscription request 5 years ago
houssine 44d20cad81 [IMP] remove unused import 5 years ago
houssine 90f1e9221a [IMP] add confirmation email on subscription form 5 years ago
houssine ac019e5c92 [IMP] add legal_form to values before partner creation 5 years ago
houssine aa405ce451 [FIX] fix redirection when cooperator is a company 5 years ago
houssine 232d2c2d8c [IMP] fix indentation 5 years ago
houssine 6ab21082e1 [IMP] retrieve value from partner 5 years ago
houssine e24a719c75 [IMP] add legal form field on the partner form 5 years ago
houssine b95f5bd60c [REFACT] remove national register number 5 years ago
houssine d050bb9be3 [IMP] value for the french localization 5 years ago
houssine 2fd6546653 [IMP] add value for the switzerland 5 years ago
houssine 93437ff98f [IMP] add value of the belgian localisation 5 years ago
houssine 8440568f9c [IMP] put class name in camel case 5 years ago
houssine 2938e23a8a [IMP] use selection_add attribute instead of overriding the whole list 5 years ago
houssine 0a91674174 [REFACT] move belgian company type to belgian localisation 5 years ago
houssine 226a804a3b [IMP] retrieve the function on the representative 5 years ago
houssine ab5dd1216f [IMP] made company form's fields readonly when logged 5 years ago
Houssine BAKKALI 1bce9250c4
Merge pull request #10 from coopiteasy/9.0-replace-nnis-by-email 5 years ago
houssine 554a4497b1 [REFACT] remove commented code 5 years ago
houssine 524abfb0b8 [IMP] replace required="True" by required="required" 5 years ago
houssine 08568e3de1 [IMP] change version and update licensing 5 years ago
houssine d4f9fc3d8f [INDENT] fix indentation 5 years ago
houssine 0e8f86195c [PEP] fix pep8 5 years ago
houssine ade9d33cd3 [IMP] make subscription field form read only 5 years ago
houssine f04528b53c [IMP] remove unused variable 5 years ago
houssine c4d854a6d1 [IMP] should be false not is_company 5 years ago
houssine da0653d76b [REFACT] replace national register number by email 5 years ago
houssine f33fa6ec7f [FIX] fix _compute_cooperator_type 5 years ago
houssine 50e7a5f756 [FIX] fix reserved variable name 5 years ago
vdewulf f2f294f71a
Update fr_BE.po for Easy My Coop 5 years ago
Houssine BAKKALI cb17a9c51b
Merge pull request #6 from coopiteasy/9.0_fix_operation_conversion 5 years ago
houssine 83ec48edfe [FIX] company_email doesn't exist on res partner 6 years ago
houssine 80e58389f1 [IMP] remove state dield from there 6 years ago
Houssine BAKKALI ac8e7c1e92
Merge pull request #5 from coopiteasy/9.0-fix-new_coop_form 6 years ago
houssine 53aca0ee6e [IMP] add check in validate function 6 years ago
Rémy Taymans 0ef913acae [FIX] emc: Error casting str to int 6 years ago
Rémy Taymans a5f633b384 [FIX] emc: Data policy and internal rules configuration 6 years ago
Rémy Taymans e494befa02
Merge pull request #4 6 years ago
Rémy Taymans a749c558f9 [IMP] emc: Data policy and internal rules approval 6 years ago
houssine f2597b3220 [PEP8] fix pep8 warning 6 years ago
houssine 0a3fe10446 [FIX] invoice payment information have been moved to another field 6 years ago
houssine 837ed8deaf [IMP] add checkbox already coop on company form 6 years ago
houssine 032b731e5a [FIX] fix checkbox not filled when logged and already coop 6 years ago
Rémy Taymans 623fef4f08 [FIX] emc: Order of approvals checkbox in new cooperator form 6 years ago
Rémy Taymans 03776220e3
Merge pull request #2 6 years ago
Rémy Taymans 54dcbd82ff [ADD] emc: Internal Rules Approved 6 years ago
Rémy Taymans 123aabf756 [CHG] emc: Remove dependence to website_legal_page 6 years ago
Rémy Taymans cdc6d083b6 [REF] emc: Duplicate key 'customer' 6 years ago
Rémy Taymans 5911b3e5bc [IMP] emc: Complete data_policy_approved processing 6 years ago
robinkeunen d7b431a202 [IMP] align already cooperator checkbox 7 years ago
robinkeunen afc28114aa [IMP] align send button 7 years ago
robinkeunen cb4a6ab8be [ADD] add website_legal_page and link to legal pages 7 years ago
robinkeunen 96f0b7f0d6 [ADD] require data policy approval 7 years ago
houssine 91dc06fc4e [IMP] take hard coded value from company field 6 years ago
houssine d909c3d32c [FIX] fix wrong field name 6 years ago
houssine 20dad701d6 [IMP] make release capital tree view use the customer invoice view tree 6 years ago
houssine ee6463c0dc [FIX] fix export. removing an old field 6 years ago
houssine f2478c9312 [IMP] make validation on iban only if iban is not empty 6 years ago
houssine ab62e69d6d [IMP] make iban field non required 6 years ago
houssine 18dce65cdc [IMP] set iban non required for this localisation 6 years ago
houssine e7cbc31932 [FIX] check no_registre only if it's required for the localisation 6 years ago
houssine 90969b1fef [FIX] fix undeclared variable domain is a special case 6 years ago
  1. 29
      easy_my_coop/__openerp__.py
  2. 128
      easy_my_coop/controllers/main.py
  3. 54
      easy_my_coop/data/mail_template_data.xml
  4. 173
      easy_my_coop/demo/coop.xml
  5. 2043
      easy_my_coop/i18n/fr.po
  6. 1781
      easy_my_coop/i18n/fr_BE.po
  7. 5
      easy_my_coop/i18n/nl_BE.po
  8. 15
      easy_my_coop/migrations/9.1.0.0.2/pre-migration.py
  9. 249
      easy_my_coop/models/account_invoice.py
  10. 68
      easy_my_coop/models/company.py
  11. 132
      easy_my_coop/models/coop.py
  12. 622
      easy_my_coop/models/operation_request.py
  13. 42
      easy_my_coop/models/partner.py
  14. 15
      easy_my_coop/report/cooperator_certificat_G001.xml
  15. 6
      easy_my_coop/view/account_invoice_view.xml
  16. 3
      easy_my_coop/view/cooperator_register_view.xml
  17. 6
      easy_my_coop/view/email_template_view.xml
  18. 33
      easy_my_coop/view/menu.xml
  19. 8
      easy_my_coop/view/menu_item_view.xml
  20. 10
      easy_my_coop/view/operation_request_view.xml
  21. 15
      easy_my_coop/view/product_view.xml
  22. 11
      easy_my_coop/view/res_company_view.xml
  23. 24
      easy_my_coop/view/res_partner_view.xml
  24. 17
      easy_my_coop/view/subscription_request_view.xml
  25. 327
      easy_my_coop/view/subscription_template.xml
  26. 41
      easy_my_coop/wizard/cooperative_history_wizard.xml
  27. 41
      easy_my_coop/wizard/create_subscription_from_partner.py
  28. 2
      easy_my_coop/wizard/create_subscription_from_partner.xml
  29. 58
      easy_my_coop/wizard/update_partner_info.py
  30. 7
      easy_my_coop/wizard/update_partner_info.xml
  31. 1
      easy_my_coop/wizard/update_share_line.py
  32. 1
      easy_my_coop_be/__init__.py
  33. 2
      easy_my_coop_be/models/__init__.py
  34. 11
      easy_my_coop_be/models/coop.py
  35. 11
      easy_my_coop_be/models/partner.py
  36. 1
      easy_my_coop_ch/__openerp__.py
  37. 3
      easy_my_coop_ch/models/__init__.py
  38. 27
      easy_my_coop_ch/models/coop.py
  39. 17
      easy_my_coop_ch/models/partner.py
  40. 13
      easy_my_coop_ch/views/subscription_request_view.xml
  41. 18
      easy_my_coop_ch/views/subscription_template.xml
  42. 3
      easy_my_coop_eater/__openerp__.py
  43. 28
      easy_my_coop_eater/demo/eaters.xml
  44. 14
      easy_my_coop_export_xlsx/wizard/export_global_wizard.py
  45. 1
      easy_my_coop_fr/models/__init__.py
  46. 10
      easy_my_coop_fr/models/coop.py
  47. 13
      easy_my_coop_fr/models/partner.py
  48. 5
      easy_my_coop_fr/views/subscription_template.xml
  49. 1
      easy_my_coop_online_payment/controllers/main.py
  50. 7
      easy_my_coop_taxshelter_report/models/tax_shelter_declaration.py
  51. 2
      easy_my_coop_website_document/__openerp__.py
  52. 2
      easy_my_coop_website_portal/__openerp__.py
  53. 2
      easy_my_coop_website_taxshelter/__openerp__.py
  54. 2
      website_portal_extend/__openerp__.py

29
easy_my_coop/__openerp__.py

@ -1,26 +1,10 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2013-2018 Open Architects Consulting SPRL.
# Copyright (C) 2018- Coop IT Easy SCRL.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# © 2013-2018 Open Architects Consulting SPRL.
# © 2018 Coop IT Easy SCRLfs. (<http://www.coopiteasy.be>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Easy My Coop",
"version": "1.1",
"version": "9.1.0.0.3",
"depends": ["base",
"sale",
"purchase",
@ -46,6 +30,7 @@
'data': [
'security/easy_my_coop_security.xml',
'security/ir.model.access.csv',
'view/menu_item_view.xml',
'wizard/create_subscription_from_partner.xml',
'wizard/update_partner_info.xml',
'wizard/validate_subscription_request.xml',
@ -60,6 +45,7 @@
'view/product_view.xml',
'view/res_company_view.xml',
'view/account_journal_view.xml',
'view/menu.xml',
'data/easy_my_coop_data.xml',
'report/easy_my_coop_report.xml',
'report/cooperator_invoice_G002.xml',
@ -68,6 +54,9 @@
'report/cooperator_register_G001.xml',
'data/mail_template_data.xml',
],
'demo': [
'demo/coop.xml',
],
'installable': True,
'application': True,
}

128
easy_my_coop/controllers/main.py

@ -13,15 +13,15 @@ _TECHNICAL = ['view_from', 'view_callback']
_BLACKLIST = ['id', 'create_uid', 'create_date', 'write_uid', 'write_date',
'user_id', 'active']
_COOP_FORM_FIELD = ['email', 'firstname', 'lastname', 'birthdate', 'iban',
'share_product_id', 'no_registre', 'address', 'city',
_COOP_FORM_FIELD = ['email', 'confirm_email', 'firstname', 'lastname',
'birthdate', 'iban', 'share_product_id', 'address', 'city',
'zip_code', 'country_id', 'phone', 'lang', 'nb_parts',
'total_parts', 'error_msg']
_COMPANY_FORM_FIELD = ['is_company', 'company_register_number', 'company_name',
'company_email', 'company_type', 'email', 'firstname',
'lastname', 'birthdate', 'iban', 'share_product_id',
'no_registre', 'address', 'city', 'zip_code',
'address', 'city', 'zip_code',
'country_id', 'phone', 'lang', 'nb_parts',
'total_parts', 'error_msg']
@ -32,13 +32,15 @@ class WebsiteSubscription(http.Controller):
'/become_cooperator'],
type='http', auth="public", website=True)
def display_become_cooperator_page(self, **kwargs):
if request.httprequest.method == "POST":
return self.share_subscription(**kwargs)
values = {}
logged = False
if request.env.user.login != 'public':
logged = True
partner = request.env.user.partner_id
if partner.is_company:
return request.website.render("easy_my_coop.becomecompanycooperator", values)
return self.display_become_company_cooperator_page()
values = self.fill_values(values, False, logged, True)
for field in _COOP_FORM_FIELD:
@ -52,6 +54,8 @@ class WebsiteSubscription(http.Controller):
'/become_company_cooperator'],
type='http', auth="public", website=True)
def display_become_company_cooperator_page(self, **kwargs):
if request.httprequest.method == "POST":
return self.share_subscription(**kwargs)
values = {}
logged = False
@ -63,7 +67,8 @@ class WebsiteSubscription(http.Controller):
if kwargs.get(field):
values[field] = kwargs.pop(field)
values.update(kwargs=kwargs.items())
return request.website.render("easy_my_coop.becomecompanycooperator", values)
return request.website.render("easy_my_coop.becomecompanycooperator",
values)
def preRenderThanks(self, values, kwargs):
""" Allow to be overrided """
@ -99,9 +104,12 @@ class WebsiteSubscription(http.Controller):
if is_company:
# company values
values['company_register_number'] = partner.company_register_number
values['company_register_number'] = (
partner.company_register_number
)
values['company_name'] = partner.name
values['company_email'] = partner.email
values['company_type'] = partner.legal_form
# contact person values
representative = partner.get_representative()
values['firstname'] = representative.firstname
@ -109,8 +117,9 @@ class WebsiteSubscription(http.Controller):
values['gender'] = representative.gender
values['email'] = representative.email
values['contact_person_function'] = representative.function
values['no_registre'] = representative.national_register_number
values['birthdate'] = self.get_date_string(representative.birthdate)
values['birthdate'] = self.get_date_string(
representative.birthdate
)
values['lang'] = representative.lang
values['phone'] = representative.phone
else:
@ -118,7 +127,6 @@ class WebsiteSubscription(http.Controller):
values['lastname'] = partner.lastname
values['email'] = partner.email
values['gender'] = partner.gender
values['no_registre'] = partner.national_register_number
values['birthdate'] = self.get_date_string(partner.birthdate)
values['lang'] = partner.lang
values['phone'] = partner.phone
@ -163,6 +171,19 @@ class WebsiteSubscription(http.Controller):
if not values.get('lang'):
if company.default_lang_id:
values['lang'] = company.default_lang_id.code
comp = request.env['res.company']._company_default_get()
values.update({
'display_internal_rules': comp.display_internal_rules_approval,
'internal_rules_required': comp.internal_rules_approval_required,
'internal_rules_text': comp.internal_rules_approval_text,
'display_data_policy': comp.display_data_policy_approval,
'data_policy_required': comp.data_policy_approval_required,
'data_policy_text': comp.data_policy_approval_text,
'display_financial_risk': comp.display_financial_risk_approval,
'financial_risk_required': comp.financial_risk_approval_required,
'financial_risk_text': comp.financial_risk_approval_text,
})
return values
def get_products_share(self, is_company):
@ -185,6 +206,11 @@ class WebsiteSubscription(http.Controller):
product_id = kwargs.get("share_product_id")
return prod_obj.sudo().browse(int(product_id)).product_variant_ids[0]
def remove_field_from_list(self, required_fields, field):
if required_fields.count(field) > 0:
required_fields.remove(field)
return required_fields
def validation(self, kwargs, logged, values, post_file):
user_obj = request.env['res.users']
sub_req_obj = request.env['subscription.request']
@ -197,12 +223,20 @@ class WebsiteSubscription(http.Controller):
if is_company:
is_company = True
redirect = "easy_my_coop.becomecompanycooperator"
email = kwargs.get('company_email')
company_email = kwargs.get('company_email')
if email == company_email:
values["error_msg"] = _("Cooperator and company emails"
" should be different.")
values = self.fill_values(values, is_company, logged)
values.update(kwargs)
return request.website.render(redirect, values)
email = company_email
if ('g-recaptcha-response' not in kwargs
or not request.website.is_captcha_valid(
kwargs['g-recaptcha-response'])):
values = self.fill_values(values, is_company, logged)
values.update(kwargs)
values["error_msg"] = _("the captcha has not been validated,"
" please fill in the captcha")
@ -210,7 +244,15 @@ class WebsiteSubscription(http.Controller):
# Check that required field from model subscription_request exists
required_fields = sub_req_obj.sudo().get_required_field()
error = set(field for field in required_fields if not values.get(field)) #noqa
if logged:
# these fields are readonly when logged
# we want to ease the process if user was a subscriber
self.remove_field_from_list(required_fields, 'iban')
self.remove_field_from_list(required_fields, 'birthdate')
error = set(
field for field in required_fields if not values.get(field)
)
if error:
values = self.fill_values(values, is_company, logged)
@ -229,6 +271,15 @@ class WebsiteSubscription(http.Controller):
"fill in the form")
return request.website.render(redirect, values)
else:
confirm_email = kwargs.get('confirm_email')
if email != confirm_email:
values = self.fill_values(values, is_company, logged)
values.update(kwargs)
values["error_msg"] = _("The email and the confirmation "
"email doesn't match.Please check "
"the given mail addresses")
return request.website.render(redirect, values)
company = request.website.company_id
if company.allow_id_card_upload:
@ -240,24 +291,15 @@ class WebsiteSubscription(http.Controller):
return request.website.render(redirect, values)
iban = kwargs.get("iban")
valid = sub_req_obj.check_iban(iban)
if iban:
valid = sub_req_obj.check_iban(iban)
if not valid:
values = self.fill_values(values, is_company, logged)
values["error_msg"] = _("You iban account number"
"is not valid")
return request.website.render(redirect, values)
if not is_company:
no_registre = re.sub('[^0-9a-zA-Z]+', '',
kwargs.get("no_registre"))
valid = sub_req_obj.check_belgian_identification_id(no_registre)
if not valid:
values = self.fill_values(values, is_company, logged)
values["error_msg"] = _("You national register number "
values.update(kwargs)
values["error_msg"] = _("You iban account number "
"is not valid")
return request.website.render(redirect, values)
values["no_registre"] = no_registre
# check the subscription's amount
max_amount = company.subscription_maximum_amount
@ -267,8 +309,9 @@ class WebsiteSubscription(http.Controller):
max_amount = max_amount - partner.total_value
if company.unmix_share_type:
share = self.get_selected_share(kwargs)
if int(partner.cooperator_type) != share.id:
if partner.cooperator_type != share.default_code:
values = self.fill_values(values, is_company, logged)
values.update(kwargs)
values["error_msg"] = (_("You can't subscribe two "
"different types of share"))
return request.website.render(redirect, values)
@ -276,6 +319,7 @@ class WebsiteSubscription(http.Controller):
if max_amount > 0 and total_amount > max_amount:
values = self.fill_values(values, is_company, logged)
values.update(kwargs)
values["error_msg"] = (_("You can't subscribe for an amount that "
"exceed ")
+ str(max_amount)
@ -298,12 +342,10 @@ class WebsiteSubscription(http.Controller):
}
}
@http.route(['/subscription/subscribe_share'],
type='http',
auth="public", website=True)
def share_subscription(self, **kwargs):
sub_req_obj = request.env['subscription.request']
attach_obj = request.env['ir.attachment']
# List of file to add to ir_attachment once we have the ID
post_file = []
# Info to add after the message
@ -338,29 +380,39 @@ class WebsiteSubscription(http.Controller):
values["already_cooperator"] = already_coop
values["is_company"] = is_company
if kwargs.get('internal_rules_approved', 'off') == 'on':
values['internal_rules_approved'] = True
if kwargs.get('data_policy_approved', 'off') == 'on':
values['data_policy_approved'] = True
if kwargs.get('financial_risk_approved', 'off') == 'on':
values['financial_risk_approved'] = True
lastname = kwargs.get("lastname").upper()
firstname = kwargs.get("firstname").title()
values["name"] = firstname + " " + lastname
values["lastname"] = lastname
values["firstname"] = firstname
values["birthdate"] = datetime.strptime(kwargs.get("birthdate"),
"%d/%m/%Y").date()
birthdate = kwargs.get("birthdate")
if birthdate:
values["birthdate"] = datetime.strptime(birthdate,
("%d/%m/%Y")).date()
else:
values["birthdate"] = False
values["source"] = "website"
values["share_product_id"] = self.get_selected_share(kwargs).id
if is_company:
if kwargs.get("company_register_number", is_company):
values["company_register_number"] = re.sub('[^0-9a-zA-Z]+',
'',
kwargs.get("company_register_number"))
values['company_type'] = kwargs.get("company_type")
if kwargs.get("company_register_number", False):
values["company_register_number"] = re.sub(
'[^0-9a-zA-Z]+', '', kwargs.get("company_register_number")
)
subscription_id = sub_req_obj.sudo().create_comp_sub_req(values)
else:
no_registre = re.sub('[^0-9a-zA-Z]+', '',
kwargs.get("no_registre"))
values["no_registre"] = no_registre
subscription_id = sub_req_obj.sudo().create(values)
if subscription_id:

54
easy_my_coop/data/mail_template_data.xml

@ -101,6 +101,60 @@
</div>
%endif
<div>
<img src=${object.company_id.logo_url}>
</div>
</div>
]]></field>
</record>
<record id="email_template_waiting_list" model="mail.template">
<field name="name">Waiting List Email</field>
<field name="email_from">${(object.company_id.coop_email_contact or object.user_id.email)|safe}</field>
<field name="subject">Subscription request added on waiting list. </field>
<field name="email_to">${object.email}</field>
<field name="reply_to">${(object.company_id.coop_email_contact or object.user_id.email)|safe}</field>
<field name="model_id" ref="model_subscription_request"/>
<field name="auto_delete" eval="True"/>
<field name="lang">${object.lang}</field>
<field name="body_html"><![CDATA[
<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; ">
<p>Hello ${object.name},</p>
<p>Thank you for your subscription request. There are currently no project to raise funds for, thus we added it on waiting list.
We will contact you as soon as the subscription requests are re-opened.
</p>
<br/>
<p>If you have any question, do not hesitate to contact us.</p>
<br/>
<p>Sustainably yours,</p>
<p>${object.company_id.name}.</p>
% if object.company_id.street:
${object.company_id.street}
% endif
% if object.company_id.street2:
${object.company_id.street2}<br/>
% endif
% if object.company_id.city or object.company_id.zip:
${object.company_id.zip} ${object.company_id.city}<br/>
% endif
% if object.company_id.country_id:
${object.company_id.state_id and ('%s, ' % object.company_id.state_id.name) or ''} ${object.company_id.country_id.name or ''}<br/>
% endif
% if object.company_id.phone:
Phone:&nbsp; ${object.company_id.phone}
% endif
% if object.company_id.website:
<div>
Web :&nbsp;<a href="${object.company_id.website}">${object.company_id.website}</a>
</div>
%endif
<div>
<img src=${object.company_id.logo_url}>
</div>

173
easy_my_coop/demo/coop.xml

@ -0,0 +1,173 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2019 Coop IT Easy
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="res_partner_cooperator_1_demo" model="res.partner">
<field name="name">Virginie Leloup</field>
<field name="customer" eval="True"/>
<field name="member" eval="True"/>
<field name="is_company" eval="False"/>
<field name="email">virginie@demo.net</field>
<field name="street">Avenue des Dessus-de-Livres, 2</field>
<field name="city">Namur (Loyers)</field>
<field name="zip">5101</field>
<field name="country_id" ref="base.be"/>
</record>
<record id="res_partner_cooperator_2_demo" model="res.partner">
<field name="name">Houssine Intégrale</field>
<field name="customer" eval="True"/>
<field name="member" eval="True"/>
<field name="is_company" eval="False"/>
<field name="email">houssine@demo.net</field>
<field name="street">Avenue des Dessous-de-Livres, 3</field>
<field name="city">Namur (Loyers)</field>
<field name="zip">5101</field>
<field name="country_id" ref="base.be"/>
</record>
<record id="res_partner_cooperator_3_demo" model="res.partner">
<field name="name">Vincent Bixolon</field>
<field name="customer" eval="True"/>
<field name="member" eval="True"/>
<field name="is_company" eval="False"/>
<field name="email">vincent@demo.net</field>
<field name="street">Rue de la colocation, 23</field>
<field name="city">Namur (Loyers)</field>
<field name="zip">5101</field>
<field name="country_id" ref="base.be"/>
</record>
<record id="res_partner_cooperator_4_demo" model="res.partner">
<field name="name">Rémy Commit</field>
<field name="customer" eval="True"/>
<field name="member" eval="True"/>
<field name="is_company" eval="False"/>
<field name="email">remy@demo.net</field>
<field name="street">Rue Guido Van Rossum, 2</field>
<field name="city">Evere</field>
<field name="zip">5101</field>
<field name="country_id" ref="base.be"/>
</record>
<record id="res_partner_cooperator_5_demo" model="res.partner">
<field name="name">Anne de Brët</field>
<field name="customer" eval="True"/>
<field name="member" eval="True"/>
<field name="is_company" eval="False"/>
<field name="email">anne@demo.net</field>
<field name="street">Rue de la patrie, 6</field>
<field name="city">Nantes</field>
<field name="zip">44000</field>
<field name="country_id" ref="base.fr"/>
</record>
<record id="res_partner_cooperator_6_demo" model="res.partner">
<field name="name">Gildo Le Floch</field>
<field name="customer" eval="True"/>
<field name="member" eval="True"/>
<field name="is_company" eval="False"/>
<field name="email">gildo@demo.net</field>
<field name="street">Rue Printanière, 8</field>
<field name="city">Evere</field>
<field name="zip">5101</field>
<field name="country_id" ref="base.be"/>
</record>
<record id="bank_account_1_demo" model="res.partner.bank">
<field name="acc_number">FR7611808009101234567890147</field>
<field name="bank_name">Bank</field>
<field name="partner_id" ref="res_partner_cooperator_1_demo"/>
</record>
<record id="bank_account_2_demo" model="res.partner.bank">
<field name="acc_number">FR7630001007941234567890185</field>
<field name="bank_name">Bank</field>
<field name="partner_id" ref="res_partner_cooperator_2_demo"/>
</record>
<record id="bank_account_3_demo" model="res.partner.bank">
<field name="acc_number">BE71096123456769</field>
<field name="bank_name">Bank</field>
<field name="partner_id" ref="res_partner_cooperator_3_demo"/>
</record>
<record id="bank_account_4_demo" model="res.partner.bank">
<field name="acc_number">BE56596123456769</field>
<field name="bank_name">Bank</field>
<field name="partner_id" ref="res_partner_cooperator_4_demo"/>
</record>
<record id="bank_account_5_demo" model="res.partner.bank">
<field name="acc_number">FR7630001007958234567890186</field>
<field name="bank_name">Bank</field>
<field name="partner_id" ref="res_partner_cooperator_5_demo"/>
</record>
<record id="bank_account_6_demo" model="res.partner.bank">
<field name="acc_number">BE71096123753769</field>
<field name="bank_name">Bank</field>
<field name="partner_id" ref="res_partner_cooperator_6_demo"/>
</record>
<record id="account_cooperator_demo" model="account.account">
<field name="code">416000</field>
<field name="name">Cooperators</field>
<field name="user_type_id" ref="account.data_account_type_receivable"/>
<field name="reconcile" eval="True"/>
</record>
<record id="product_template_share_type_1_demo" model="product.template">
<field name="name">Part A - Founder</field>
<field name="short_name">Part A</field>
<field name="is_share" eval="True"/>
<field name="default_share_product" eval="True"/>
<field name="force_min_qty" eval="True"/>
<field name="minimum_quantity">2</field>
<field name="by_individual" eval="True"/>
<field name="by_company" eval="True"/>
<field name="list_price">50</field>
<field name="display_on_website" eval="True"/>
</record>
<record id="product_product_share_type_1_demo" model="product.product">
<field name="product_tmpl_id" ref="product_template_share_type_1_demo"/>
<field name="default_code">share_a</field>
</record>
<record id="product_template_share_type_2_demo" model="product.template">
<field name="name">Part B - Worker</field>
<field name="short_name">Part B</field>
<field name="is_share" eval="True"/>
<field name="default_share_product" eval="True"/>
<field name="force_min_qty" eval="True"/>
<field name="minimum_quantity">2</field>
<field name="by_individual" eval="True"/>
<field name="by_company" eval="False"/>
<field name="list_price">25</field>
<field name="display_on_website" eval="True"/>
</record>
<record id="product_product_share_type_2_demo" model="product.product">
<field name="product_tmpl_id" ref="product_template_share_type_2_demo"/>
<field name="default_code">share_b</field>
</record>
<record id="subscription_request_1_demo" model="subscription.request">
<field name="name">Manuel Dublues</field>
<field name="email">manuel@demo.net</field>
<field name="address">schaerbeekstraat</field>
<field name="zip_code">1111</field>
<field name="city">Brussels</field>
<field name="country_id" ref="base.be"/>
<field name="date" eval="datetime.now() - timedelta(days=12)"/>
<field name="source">manual</field>
<field name="ordered_parts">3</field>
<field name="share_product_id" ref="product_product_share_type_1_demo"/>
<field name="lang">en_US</field>
</record>
</odoo>

2043
easy_my_coop/i18n/fr.po
File diff suppressed because it is too large
View File

1781
easy_my_coop/i18n/fr_BE.po
File diff suppressed because it is too large
View File

5
easy_my_coop/i18n/nl_BE.po

@ -439,6 +439,11 @@ msgstr "25"
msgid "<p>Access this document <a href=\"%s\">directly in OpenERP</a></p>"
msgstr "<p>Access this document <a href=\"%s\">directly in OpenERP</a></p>"
#. module: easy_my_coop
#: model:ir.ui.view,arch_db:easy_my_coop.cooperator_certificat_G001_document
msgid "<span> Certificate generated on </span>"
msgstr "<span> Certificate generated on </span>"
#. module: easy_my_coop
#: model:ir.ui.view,arch_db:easy_my_coop.cooperator_certificat_G001_document
msgid "<span> is recorded in the register of cooperators under number </span>"

15
easy_my_coop/migrations/9.1.0.0.2/pre-migration.py

@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
def migrate(cr, version):
if not version:
return
cr.execute("UPDATE res_company "
"SET internal_rules_approval_required = FALSE "
"WHERE display_internal_rules_approval = FALSE")
cr.execute("UPDATE res_company "
"SET data_policy_approval_required = FALSE "
"WHERE display_data_policy_approval = FALSE")
cr.execute("UPDATE res_company "
"SET financial_risk_approval_required = FALSE "
"WHERE display_financial_risk_approval = FALSE")

249
easy_my_coop/models/account_invoice.py

@ -1,124 +1,125 @@
# -*- coding: utf-8 -*-
from datetime import datetime
from openerp import api, fields, models
class account_invoice(models.Model):
_inherit = 'account.invoice'
subscription_request = fields.Many2one('subscription.request',
string='Subscription request')
release_capital_request = fields.Boolean(
string='Release of capital request')
@api.model
def _prepare_refund(self, invoice, date_invoice=None, date=None,
description=None, journal_id=None):
values = super(account_invoice, self)._prepare_refund(
invoice, date_invoice, date,
description, journal_id)
values['release_capital_request'] = self.release_capital_request
return values
def create_user(self, partner):
user_obj = self.env['res.users']
email = partner.email
if partner.is_company:
email = partner.company_email
user = user_obj.search([('login', '=', email)])
if not user:
user = user_obj.search([('login', '=', email),
('active', '=', False)])
if user:
user.sudo().write({'active': True})
else:
user_values = {'partner_id': partner.id, 'login': email}
user_id = user_obj.sudo()._signup_create_user(user_values)
user = user_obj.browse(user_id)
user.sudo().with_context({'create_user': True}).action_reset_password()
return True
def set_cooperator_effective(self, effective_date):
# flag the partner as a effective member
mail_template_id = 'easy_my_coop.email_template_certificat'
# if not yet cooperator we generate a cooperator number
if self.partner_id.member is False and self.partner_id.old_member is False:
sequence_id = self.env.ref('easy_my_coop.sequence_subscription', False)
sub_reg_num = sequence_id.next_by_id()
self.partner_id.write({
'member': True, 'old_member': False,
'cooperator_register_number': int(sub_reg_num)})
elif self.partner_id.old_member:
self.partner_id.write({'member': True, 'old_member': False})
else:
mail_template_id = 'easy_my_coop.email_template_certificat_increase'
sequence_operation = self.env.ref('easy_my_coop.sequence_register_operation', False)
sub_reg_operation = sequence_operation.next_by_id()
certificat_email_template = self.env.ref(mail_template_id, False)
for line in self.invoice_line_ids:
self.env['subscription.register'].create({
'name': sub_reg_operation,
'register_number_operation': int(sub_reg_operation),
'partner_id': self.partner_id.id,
'quantity': line.quantity,
'share_product_id': line.product_id.id,
'share_unit_price': line.price_unit,
'date': effective_date,
'type': 'subscription'})
self.env['share.line'].create({
'share_number': line.quantity,
'share_product_id': line.product_id.id,
'partner_id': self.partner_id.id,
'share_unit_price': line.price_unit,
'effective_date': effective_date
})
if line.product_id.mail_template:
certificat_email_template = line.product_id.mail_template
# we send the email with the certificat in attachment
certificat_email_template.send_mail(self.partner_id.id, False)
if self.company_id.create_user:
self.create_user(self.partner_id)
return True
def post_process_confirm_paid(self, effective_date):
self.set_cooperator_effective(effective_date)
return True
@api.multi
def confirm_paid(self):
for invoice in self:
super(account_invoice, invoice).confirm_paid()
# we check if there is an open refund for this invoice. in this
# case we don't run the process_subscription function as the
# invoice has been reconciled with a refund and not a payment.
refund = self.search([('type', '=', 'out_refund'),
('origin', '=', invoice.move_name)])
if invoice.partner_id.cooperator and invoice.release_capital_request \
and invoice.type == 'out_invoice' and not refund:
# take the effective date from the payment.
# by default the confirmation date is the payment date
effective_date = datetime.now().strftime("%d/%m/%Y")
if invoice.payment_move_line_ids:
move_line = invoice.payment_move_line_ids[0]
effective_date = move_line.date
invoice.subscription_request.state = 'paid'
invoice.post_process_confirm_paid(effective_date)
# if there is a open refund we mark the subscription as cancelled
elif invoice.partner_id.cooperator and invoice.release_capital_request \
and invoice.type == 'out_invoice' and refund:
invoice.subscription_request.state = 'cancelled'
return True
# -*- coding: utf-8 -*-
from datetime import datetime
from openerp import api, fields, models
class AccountInvoice(models.Model):
_inherit = 'account.invoice'
subscription_request = fields.Many2one('subscription.request',
string='Subscription request')
release_capital_request = fields.Boolean(
string='Release of capital request')
@api.model
def _prepare_refund(self, invoice, date_invoice=None, date=None,
description=None, journal_id=None):
values = super(AccountInvoice, self)._prepare_refund(
invoice, date_invoice, date,
description, journal_id)
values['release_capital_request'] = self.release_capital_request
return values
def create_user(self, partner):
user_obj = self.env['res.users']
email = partner.email
user = user_obj.search([('login', '=', email)])
if not user:
user = user_obj.search([('login', '=', email),
('active', '=', False)])
if user:
user.sudo().write({'active': True})
else:
user_values = {'partner_id': partner.id, 'login': email}
user_id = user_obj.sudo()._signup_create_user(user_values)
user = user_obj.browse(user_id)
user.sudo().with_context({'create_user': True}).action_reset_password()
return True
def set_cooperator_effective(self, effective_date):
# flag the partner as a effective member
mail_template_id = 'easy_my_coop.email_template_certificat'
# if not yet cooperator we generate a cooperator number
if self.partner_id.member is False and self.partner_id.old_member is False:
sequence_id = self.env.ref('easy_my_coop.sequence_subscription', False)
sub_reg_num = sequence_id.next_by_id()
self.partner_id.write({
'member': True, 'old_member': False,
'cooperator_register_number': int(sub_reg_num)})
elif self.partner_id.old_member:
self.partner_id.write({'member': True, 'old_member': False})
else:
mail_template_id = 'easy_my_coop.email_template_certificat_increase'
sequence_operation = self.env.ref('easy_my_coop.sequence_register_operation', False)
sub_reg_operation = sequence_operation.next_by_id()
certificat_email_template = self.env.ref(mail_template_id, False)
for line in self.invoice_line_ids:
self.env['subscription.register'].create({
'name': sub_reg_operation,
'register_number_operation': int(sub_reg_operation),
'partner_id': self.partner_id.id,
'quantity': line.quantity,
'share_product_id': line.product_id.id,
'share_unit_price': line.price_unit,
'date': effective_date,
'type': 'subscription'})
self.env['share.line'].create({
'share_number': line.quantity,
'share_product_id': line.product_id.id,
'partner_id': self.partner_id.id,
'share_unit_price': line.price_unit,
'effective_date': effective_date
})
if line.product_id.mail_template:
certificat_email_template = line.product_id.mail_template
# we send the email with the certificat in attachment
certificat_email_template.send_mail(self.partner_id.id, False)
if self.company_id.create_user:
self.create_user(self.partner_id)
return True
def post_process_confirm_paid(self, effective_date):
self.set_cooperator_effective(effective_date)
return True
@api.multi
def confirm_paid(self):
for invoice in self:
super(AccountInvoice, invoice).confirm_paid()
# we check if there is an open refund for this invoice. in this
# case we don't run the process_subscription function as the
# invoice has been reconciled with a refund and not a payment.
# FIXME if the is a cancelled or a draft refund it takes it as open
# check if at this stage the refund is open and in this case add
# the state to the search domain
refund = self.search([('type', '=', 'out_refund'),
('origin', '=', invoice.move_name)])
if invoice.partner_id.cooperator and invoice.release_capital_request \
and invoice.type == 'out_invoice' and not refund:
# take the effective date from the payment.
# by default the confirmation date is the payment date
effective_date = datetime.now().strftime("%d/%m/%Y")
if invoice.payment_move_line_ids:
move_line = invoice.payment_move_line_ids[0]
effective_date = move_line.date
invoice.subscription_request.state = 'paid'
invoice.post_process_confirm_paid(effective_date)
# if there is a open refund we mark the subscription as cancelled
elif invoice.partner_id.cooperator and invoice.release_capital_request \
and invoice.type == 'out_invoice' and refund:
invoice.subscription_request.state = 'cancelled'
return True

68
easy_my_coop/models/company.py

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from openerp import fields, models
from openerp import api, fields, models
class ResCompany(models.Model):
@ -44,3 +44,69 @@ class ResCompany(models.Model):
bottom_logo2 = fields.Binary(string="Bottom logo 2")
logo_url = fields.Char(string="logo url",
compute="_get_base_logo")
display_internal_rules_approval = fields.Boolean(
help="Choose to display an internal rules checkbox on the"
" cooperator website form."
)
internal_rules_approval_required = fields.Boolean(
string="Is internal rules approval required?"
)
internal_rules_approval_text = fields.Html(
translate=True,
help="Text to display aside the checkbox to approve internal rules."
)
display_data_policy_approval = fields.Boolean(
help="Choose to display a data policy checkbox on the cooperator"
" website form."
)
data_policy_approval_required = fields.Boolean(
string="Is data policy approval required?"
)
data_policy_approval_text = fields.Html(
translate=True,
help="Text to display aside the checkbox to approve data policy."
)
display_financial_risk_approval = fields.Boolean(
help="Choose to display a financial risk checkbox on the"
" cooperator website form."
)
financial_risk_approval_required = fields.Boolean(
string="Is financial risk approval required?"
)
financial_risk_approval_text = fields.Html(
translate=True,
help="Text to display aside the checkbox to approve financial risk."
)
@api.onchange('internal_rules_approval_required')
def onchange_internal_rules_approval_required(self):
if self.internal_rules_approval_required:
self.display_internal_rules_approval = True
@api.onchange('data_policy_approval_required')
def onchange_data_policy_approval_required(self):
if self.data_policy_approval_required:
self.display_data_policy_approval = True
@api.onchange('financial_risk_approval_required')
def onchange_financial_risk_approval_required(self):
if self.financial_risk_approval_required:
self.display_financial_risk_rules_approval = True
_sql_constraints = [(
'approval_constraint',
"""CHECK (((internal_rules_approval_required=FALSE
AND display_internal_rules_approval=FALSE)
OR display_internal_rules_approval=TRUE)
AND ((data_policy_approval_required=FALSE
AND display_data_policy_approval=FALSE)
OR display_data_policy_approval=TRUE)
AND ((financial_risk_approval_required=FALSE
AND display_financial_risk_approval=FALSE)
OR display_financial_risk_approval=TRUE))
""",
"Approval can't be mandatory and not displayed."
)]

132
easy_my_coop/models/coop.py

@ -15,7 +15,6 @@ _REQUIRED = ['email',
'zip_code',
'city',
'iban',
'no_registre',
'gender'] # Could be improved including required from model
@ -30,19 +29,27 @@ class subscription_request(models.Model):
_description = 'Subscription Request'
def get_required_field(self):
return _REQUIRED
required_fields = _REQUIRED
company = self.env['res.company']._company_default_get()
if company.internal_rules_approval_required:
required_fields.append('internal_rules_approved')
if company.data_policy_approval_required:
required_fields.append('data_policy_approved')
if company.financial_risk_approval_required:
required_fields.append('financial_risk_approved')
return required_fields
@api.model
def create(self, vals):
partner_obj = self.env['res.partner']
if not vals.get('partner_id'):
cooperator = False
if vals.get('no_registre'):
cooperator = partner_obj.get_cooperator_from_nin(
vals.get('no_registre'))
if vals.get('email'):
cooperator = partner_obj.get_cooperator_from_email(
vals.get('email'))
if cooperator:
# TODO remove the following line of code once it has
# been founded a way to avoid dubble entry
# been found a way to avoid double entry
cooperator = cooperator[0]
if cooperator.member:
vals['type'] = 'increase'
@ -83,22 +90,6 @@ class subscription_request(models.Model):
return subscr_request
def check_belgian_identification_id(self, nat_register_num):
if not self.check_empty_string(nat_register_num):
return False
if len(nat_register_num) != 11:
return False
if not nat_register_num.isdigit():
return False
birthday_number = nat_register_num[0:9]
controle = nat_register_num[9:11]
check_controle = 97 - (int(birthday_number) % 97)
if int(check_controle) != int(controle):
check_controle = 97 - ((2000000000 + int(birthday_number)) % 97)
if int(check_controle) != int(controle):
return False
return True
def check_empty_string(self, value):
if value is None or value is False or value == '':
return False
@ -113,17 +104,12 @@ class subscription_request(models.Model):
return validated
@api.multi
@api.depends('iban', 'no_registre', 'skip_control_ng', 'is_company')
@api.depends('iban', 'skip_control_ng', 'is_company')
def _validated_lines(self):
for sub_request in self:
validated = self.check_iban(sub_request.iban)
if validated and (sub_request.skip_control_ng or
self.check_belgian_identification_id(
sub_request.no_registre)):
validated = True
else:
validated = False
validated = (self.check_iban(sub_request.iban)
or sub_request.skip_control_ng
)
sub_request.validated = validated
@api.multi
@ -228,9 +214,6 @@ class subscription_request(models.Model):
phone = fields.Char(string='Phone',
readonly=True,
states={'draft': [('readonly', False)]})
no_registre = fields.Char(string='National Register Number',
readonly=True,
states={'draft': [('readonly', False)]})
user_id = fields.Many2one('res.users',
string='Responsible',
readonly=True)
@ -254,8 +237,11 @@ class subscription_request(models.Model):
required=True,
readonly=True,
states={'draft': [('readonly', False)]},
default=lambda self: datetime.strftime(datetime.now(), '%Y-%m-%d'))
company_id = fields.Many2one('res.company', string='Company', required=True,
default=lambda self: datetime.strftime(datetime.now(),
'%Y-%m-%d'))
company_id = fields.Many2one('res.company',
string='Company',
required=True,
change_default=True,
readonly=True,
default=lambda self: self.env['res.company']._company_default_get())
@ -274,11 +260,7 @@ class subscription_request(models.Model):
company_register_number = fields.Char(string='Company register number',
readonly=True,
states={'draft': [('readonly', False)]})
company_type = fields.Selection([('scrl', 'SCRL'),
('asbl', 'ASBL'),
('sprl', 'SPRL'),
('sa', 'SA'),
('other', 'Other')],
company_type = fields.Selection([('', '')],
string="Company type",
readonly=True,
states={'draft': [('readonly', False)]})
@ -326,13 +308,33 @@ class subscription_request(models.Model):
default="website",
readonly=True,
states={'draft': [('readonly', False)]})
internal_rules_approved = fields.Boolean(
string='Internal Rules Approved ',
default=False,
)
data_policy_approved = fields.Boolean(
string='Data Policy Approved',
default=False,
)
financial_risk_approved = fields.Boolean(
string='Financial Risk Approved',
default=False,
)
_order = "id desc"
@api.multi
@api.constrains("company_email", "email")
def _check_company_email(self):
"""Ensure that company_email and email are different"""
for sub_req in self:
if sub_req.company_email == sub_req.email:
raise UserError(_("Company email and email can't "
"be the same."))
def get_person_info(self, partner):
self.firstname = partner.firstname
self.name = partner.name
self.lastname = partner.lastname
self.no_registre = partner.national_register_number
self.email = partner.email
self.birthdate = partner.birthdate_date
self.gender = partner.gender
@ -391,7 +393,7 @@ class subscription_request(models.Model):
return res
def send_capital_release_request(self, invoice):
invoice_email_template = self.env['mail.template'].search([('name', '=', 'Request to Release Capital - Send by Email')])[0]
invoice_email_template = self.env.ref('easy_my_coop.email_template_release_capital', False)
# we send the email with the capital release request in attachment
invoice_email_template.send_mail(invoice.id, True)
@ -433,15 +435,20 @@ class subscription_request(models.Model):
partner_vals = {'name': self.company_name,
'last_name': self.company_name,
'is_company': self.is_company,
'legal_form': self.company_type,
'company_register_number': self.company_register_number, #noqa
'customer': False, 'cooperator': True,
'cooperator': True,
'street': self.address, 'zip': self.zip_code,
'city': self.city, 'email': self.company_email,
'out_inv_comm_type': 'bba',
'customer': self.share_product_id.customer,
'out_inv_comm_algorithm': 'random',
'country_id': self.country_id.id,
'lang': self.lang}
'lang': self.lang,
'internal_rules_approved': self.internal_rules_approved,
'data_policy_approved': self.data_policy_approved,
'financial_risk_approved': self.financial_risk_approved
}
return partner_vals
def get_partner_vals(self):
@ -450,12 +457,15 @@ class subscription_request(models.Model):
'zip': self.zip_code, 'email': self.email,
'gender': self.gender, 'cooperator': True,
'city': self.city, 'phone': self.phone,
'national_register_number': self.no_registre,
'out_inv_comm_type': 'bba',
'out_inv_comm_algorithm': 'random',
'country_id': self.country_id.id, 'lang': self.lang,
'birthdate_date': self.birthdate,
'customer': self.share_product_id.customer}
'customer': self.share_product_id.customer,
'internal_rules_approved': self.internal_rules_approved,
'data_policy_approved': self.data_policy_approved,
'financial_risk_approved': self.financial_risk_approved
}
return partner_vals
def create_coop_partner(self):
@ -481,30 +491,35 @@ class subscription_request(models.Model):
if self.ordered_parts <= 0:
raise UserError(_('Number of share must be greater than 0.'))
if self.partner_id:
if not self.partner_id.cooperator:
self.partner_id.cooperator = True
partner = self.partner_id
else:
partner = None
domain = []
if self.already_cooperator:
raise UserError(_('The checkbox already cooperator is'
' checked please select a cooperator.'))
elif self.is_company and self.company_register_number:
domain = [('company_register_number', '=', self.company_register_number)] #noqa
elif not self.is_company and self.no_registre:
domain = [('national_register_number', '=', self.no_registre)]
elif not self.is_company and self.email:
domain = [('email', '=', self.email)]
partner = partner_obj.search(domain)
if domain:
partner = partner_obj.search(domain)
if not partner:
partner = self.create_coop_partner()
else:
partner = partner[0]
partner.write({
"cooperator": True,
"customer": self.share_product_id.customer
})
if self.is_company and not partner.has_representative():
contact = False
if self.no_registre:
domain = [('national_register_number', '=', self.no_registre)]
if self.email:
domain = [('email', '=', self.email)]
contact = partner_obj.search(domain)
if contact:
contact.type = 'representative'
@ -516,7 +531,6 @@ class subscription_request(models.Model):
'street': self.address, 'gender': self.gender,
'zip': self.zip_code, 'city': self.city,
'phone': self.phone, 'email': self.email,
'national_register_number': self.no_registre,
'country_id': self.country_id.id,
'out_inv_comm_type': 'bba',
'out_inv_comm_algorithm': 'random',
@ -525,7 +539,11 @@ class subscription_request(models.Model):
'parent_id': partner.id,
'representative': True,
'function': self.contact_person_function,
'type': 'representative'}
'type': 'representative',
'internal_rules_approved': self.internal_rules_approved,
'data_policy_approved': self.data_policy_approved,
'financial_risk_approved': self.financial_risk_approved
}
contact = partner_obj.create(contact_vals)
else:
if len(contact) > 1:
@ -560,6 +578,8 @@ class subscription_request(models.Model):
@api.one
def put_on_waiting_list(self):
waiting_list_mail_template = self.env.ref('easy_my_coop.email_template_waiting_list', False)
waiting_list_mail_template.send_mail(self.id, True)
self.write({'state': 'waiting'})

622
easy_my_coop/models/operation_request.py

@ -1,303 +1,319 @@
# -*- coding: utf-8 -*-
from datetime import datetime
from openerp import api, fields, models, _
from openerp.exceptions import ValidationError
class operation_request(models.Model):
_name = 'operation.request'
def get_date_now(self):
return datetime.strftime(datetime.now(), '%Y-%m-%d')
@api.multi
@api.depends('share_product_id', 'share_product_id.list_price', 'quantity')
def _compute_subscription_amount(self):
for operation_request in self:
operation_request.subscription_amount = (operation_request.
share_product_id.
list_price *
operation_request.
quantity)
request_date = fields.Date(string='Request date',
default=lambda self: self.get_date_now())
partner_id = fields.Many2one('res.partner',
string='Cooperator',
domain=[('member', '=', True)],
required=True)
partner_id_to = fields.Many2one('res.partner',
string='Transfered to',
domain=[('cooperator', '=', True)])
operation_type = fields.Selection([('subscription', 'Subscription'),
('transfer', 'Transfer'),
('sell_back', 'Sell Back'),
('convert', 'Conversion')],
string='Operation Type',
required=True)
share_product_id = fields.Many2one('product.product',
string='Share type',
domain=[('is_share', '=', True)],
required=True)
share_to_product_id = fields.Many2one('product.product',
string='Convert to this share type',
domain=[('is_share', '=', True)])
share_short_name = fields.Char(related='share_product_id.short_name',
string='Share type name')
share_to_short_name = fields.Char(related='share_to_product_id.short_name',
string='Share to type name')
share_unit_price = fields.Float(related='share_product_id.list_price',
string='Share price')
share_to_unit_price = fields.Float(related='share_to_product_id.list_price',
string='Share to price')
subscription_amount = fields.Float(compute='_compute_subscription_amount',
string='Operation amount')
quantity = fields.Integer(string='Number of share',
required=True)
state = fields.Selection([('draft', 'Draft'),
('waiting', 'Waiting'),
('approved', 'Approved'),
('done', 'Done'),
('cancelled', 'Cancelled'),
('refused', 'Refused')],
string='State',
required=True,
default='draft')
user_id = fields.Many2one('res.users',
string='Responsible',
readonly=True,
default=lambda self: self.env.user)
subscription_request = fields.One2many('subscription.request',
'operation_request_id',
string="Share Receiver Info",
help="In case on a transfer of"
" share. If the share receiver"
" isn't a effective member then a"
" subscription form should"
" be filled.")
receiver_not_member = fields.Boolean(string='Receiver is not a member')
company_id = fields.Many2one('res.company',
string='Company',
required=True,
change_default=True,
readonly=True,
default=lambda self: self.env['res.company']._company_default_get())
invoice = fields.Many2one('account.invoice',
string="Invoice")
@api.multi
def approve_operation(self):
for rec in self:
rec.write({'state': 'approved'})
@api.multi
def refuse_operation(self):
for rec in self:
rec.write({'state': 'refused'})
@api.multi
def submit_operation(self):
for rec in self:
rec.validate()
rec.write({'state': 'waiting'})
@api.multi
def cancel_operation(self):
for rec in self:
rec.write({'state': 'cancelled'})
@api.multi
def reset_to_draft(self):
for rec in self:
rec.write({'state': 'draft'})
def get_total_share_dic(self, partner):
total_share_dic = {}
share_products = self.env['product.template'].search([('is_share', '=', True)])
for share_product in share_products:
total_share_dic[share_product.id] = 0
for line in partner.share_ids:
total_share_dic[line.share_product_id.id] += line.share_number
return total_share_dic
# This function doesn't handle the case of a cooperator can own
# different kinds of share type
def hand_share_over(self, partner, share_product_id, quantity):
if not partner.member:
raise ValidationError(_("This operation can't be executed if the"
" cooperator is not an effective member"))
share_ind = len(partner.share_ids)
i = 1
while quantity > 0:
line = self.partner_id.share_ids[share_ind-i]
if line.share_product_id.id == share_product_id.id:
if quantity > line.share_number:
quantity -= line.share_number
line.unlink()
else:
share_left = line.share_number - quantity
quantity = 0
line.write({'share_number': share_left})
i += 1
# if the cooperator sold all his shares he's no more
# an effective member
remaning_share_dict = 0
for share_quant in self.get_total_share_dic(partner).values():
remaning_share_dict += share_quant
if remaning_share_dict == 0:
self.partner_id.write({'member': False, 'old_member': True})
def has_share_type(self):
for line in self.partner_id.share_ids:
if line.share_product_id.id == self.share_product_id.id:
return True
return False
def validate(self):
if not self.has_share_type() and \
self.operation_type in ['sell_back', 'transfer']:
raise ValidationError(_("The cooperator doesn't own this share"
" type. Please choose the appropriate"
" share type."))
if self.operation_type in ['sell_back', 'convert', 'transfer']:
total_share_dic = self.get_total_share_dic(self.partner_id)
if self.quantity > total_share_dic[self.share_product_id.id]:
raise ValidationError(_("The cooperator can't hand over more"
" shares that he/she owns."))
if self.operation_type == 'convert':
if self.company_id.unmix_share_type:
if self.share_product_id.code == self.share_to_product_id.code:
raise ValidationError(_("You can't convert the share to"
" the same share type."))
if self.subscription_amount != self.partner_id.total_value:
raise ValidationError(_("You must convert all the shares"
" to the selected type."))
else:
if self.subscription_amount != self.partner_id.total_value:
raise ValidationError(_("Converting just part of the"
" shares is not yet implemented"))
elif self.operation_type == 'transfer':
if not self.receiver_not_member and self.company_id.unmix_share_type \
and (self.partner_id_to.cooperator_type
and self.partner_id.cooperator_type != self.partner_id_to.cooperator_type):
raise ValidationError(_("This share type could not be"
" transfered to " +
self.partner_id_to.name))
if self.receiver_not_member and self.subscription_request \
and not self.subscription_request.validated:
raise ValidationError(_("The information of the receiver"
" are not correct. Please correct"
" the information before"
" submitting"))
@api.multi
def execute_operation(self):
self.ensure_one()
effective_date = self.get_date_now()
sub_request = self.env['subscription.request']
for rec in self:
rec.validate()
if rec.state != 'approved':
raise ValidationError(_("This operation must be approved"
" before to be executed"))
values = {
'partner_id': rec.partner_id.id, 'quantity': rec.quantity,
'share_product_id': rec.share_product_id.id,
'type': rec.operation_type,
'share_unit_price': rec.share_unit_price,
'date': effective_date,
}
if rec.operation_type == 'sell_back':
self.hand_share_over(rec.partner_id, rec.share_product_id,
rec.quantity)
elif rec.operation_type == 'convert':
amount_to_convert = rec.share_unit_price * rec.quantity
convert_quant = int(amount_to_convert / rec.share_to_product_id.list_price)
remainder = amount_to_convert % rec.share_to_product_id.list_price
if convert_quant > 0 and remainder == 0:
share_ids = rec.partner_id.share_ids
line = share_ids[0]
if len(share_ids) > 1:
share_ids[1:len(share_ids)].unlink()
line.write({
'share_number': convert_quant,
'share_product_id': rec.share_to_product_id.id,
'share_unit_price': rec.share_to_unit_price,
'share_short_name': rec.share_to_short_name
})
values['share_to_product_id'] = rec.share_to_product_id.id
values['quantity_to'] = convert_quant
else:
raise ValidationError(_("Converting just part of the"
" shares is not yet implemented"))
elif rec.operation_type == 'transfer':
sequence_id = self.env.ref('easy_my_coop.sequence_subscription', False)
if rec.receiver_not_member:
partner = rec.subscription_request.create_coop_partner()
# get cooperator number
sub_reg_num = int(sequence_id.next_by_id())
partner_vals = sub_request.get_eater_vals(partner, rec.share_product_id)
partner_vals['member'] = True
partner_vals['cooperator_register_number'] = sub_reg_num
partner.write(partner_vals)
rec.partner_id_to = partner
else:
# means an old member or cooperator candidate
if not rec.partner_id_to.member:
if rec.partner_id_to.cooperator_register_number == 0:
sub_reg_num = int(sequence_id.next_by_id())
partner_vals['cooperator_register_number'] = sub_reg_num
partner_vals = sub_request.get_eater_vals(
rec.partner_id_to,
rec.share_product_id)
partner_vals['member'] = True
partner_vals['old_member'] = False
rec.partner_id_to.write(partner_vals)
# remove the parts to the giver
self.hand_share_over(rec.partner_id,
rec.share_product_id,
rec.quantity)
# give the share to the receiver
self.env['share.line'].create({
'share_number': rec.quantity,
'partner_id': rec.partner_id_to.id,
'share_product_id': rec.share_product_id.id,
'share_unit_price': rec.share_unit_price,
'effective_date': effective_date})
values['partner_id_to'] = rec.partner_id_to.id
else:
raise ValidationError(_("This operation is not yet"
" implemented."))
sequence_operation = self.env.ref('easy_my_coop.sequence_register_operation', False)
sub_reg_operation = sequence_operation.next_by_id()
values['name'] = sub_reg_operation
values['register_number_operation'] = int(sub_reg_operation)
rec.write({'state': 'done'})
# send mail to the receiver
if rec.operation_type == 'transfer':
certificat_email_template = self.env.ref('easy_my_coop.email_template_share_transfer', False)
certificat_email_template.send_mail(rec.partner_id_to.id, False)
self.env['subscription.register'].create(values)
certificat_email_template = self.env.ref('easy_my_coop.email_template_share_update', False)
certificat_email_template.send_mail(rec.partner_id.id, False)
# -*- coding: utf-8 -*-
from datetime import datetime
from openerp import api, fields, models, _
from openerp.exceptions import ValidationError
class operation_request(models.Model):
_name = 'operation.request'
def get_date_now(self):
return datetime.strftime(datetime.now(), '%Y-%m-%d')
@api.multi
@api.depends('share_product_id', 'share_product_id.list_price', 'quantity')
def _compute_subscription_amount(self):
for operation_request in self:
operation_request.subscription_amount = (operation_request.
share_product_id.
list_price *
operation_request.
quantity)
request_date = fields.Date(string='Request date',
default=lambda self: self.get_date_now())
partner_id = fields.Many2one('res.partner',
string='Cooperator',
domain=[('member', '=', True)],
required=True)
partner_id_to = fields.Many2one('res.partner',
string='Transfered to',
domain=[('cooperator', '=', True)])
operation_type = fields.Selection([('subscription', 'Subscription'),
('transfer', 'Transfer'),
('sell_back', 'Sell Back'),
('convert', 'Conversion')],
string='Operation Type',
required=True)
share_product_id = fields.Many2one('product.product',
string='Share type',
domain=[('is_share', '=', True)],
required=True)
share_to_product_id = fields.Many2one('product.product',
string='Convert to this share type',
domain=[('is_share', '=', True)])
share_short_name = fields.Char(related='share_product_id.short_name',
string='Share type name')
share_to_short_name = fields.Char(related='share_to_product_id.short_name',
string='Share to type name')
share_unit_price = fields.Float(related='share_product_id.list_price',
string='Share price')
share_to_unit_price = fields.Float(related='share_to_product_id.list_price',
string='Share to price')
subscription_amount = fields.Float(compute='_compute_subscription_amount',
string='Operation amount')
quantity = fields.Integer(string='Number of share',
required=True)
state = fields.Selection([('draft', 'Draft'),
('waiting', 'Waiting'),
('approved', 'Approved'),
('done', 'Done'),
('cancelled', 'Cancelled'),
('refused', 'Refused')],
string='State',
required=True,
default='draft')
user_id = fields.Many2one('res.users',
string='Responsible',
readonly=True,
default=lambda self: self.env.user)
subscription_request = fields.One2many('subscription.request',
'operation_request_id',
string="Share Receiver Info",
help="In case on a transfer of"
" share. If the share receiver"
" isn't a effective member then a"
" subscription form should"
" be filled.")
receiver_not_member = fields.Boolean(string='Receiver is not a member')
company_id = fields.Many2one('res.company',
string='Company',
required=True,
change_default=True,
readonly=True,
default=lambda self: self.env['res.company']._company_default_get())
invoice = fields.Many2one('account.invoice',
string="Invoice")
@api.multi
def approve_operation(self):
for rec in self:
rec.write({'state': 'approved'})
@api.multi
def refuse_operation(self):
for rec in self:
rec.write({'state': 'refused'})
@api.multi
def submit_operation(self):
for rec in self:
rec.validate()
rec.write({'state': 'waiting'})
@api.multi
def cancel_operation(self):
for rec in self:
rec.write({'state': 'cancelled'})
@api.multi
def reset_to_draft(self):
for rec in self:
rec.write({'state': 'draft'})
def get_total_share_dic(self, partner):
total_share_dic = {}
prod_template_obj = self.env['product.product']
share_products = prod_template_obj.search([('is_share', '=', True)])
for share_product in share_products:
total_share_dic[share_product.id] = 0
for line in partner.share_ids:
total_share_dic[line.share_product_id.id] += line.share_number
return total_share_dic
# This function doesn't handle the case of a cooperator can own
# different kinds of share type
def hand_share_over(self, partner, share_product_id, quantity):
if not partner.member:
raise ValidationError(_("This operation can't be executed if the"
" cooperator is not an effective member"))
share_ind = len(partner.share_ids)
i = 1
while quantity > 0:
line = self.partner_id.share_ids[share_ind-i]
if line.share_product_id.id == share_product_id.id:
if quantity > line.share_number:
quantity -= line.share_number
line.unlink()
else:
share_left = line.share_number - quantity
quantity = 0
line.write({'share_number': share_left})
i += 1
# if the cooperator sold all his shares he's no more
# an effective member
remaning_share_dict = 0
for share_quant in self.get_total_share_dic(partner).values():
remaning_share_dict += share_quant
if remaning_share_dict == 0:
self.partner_id.write({'member': False, 'old_member': True})
def has_share_type(self):
for line in self.partner_id.share_ids:
if line.share_product_id.id == self.share_product_id.id:
return True
return False
def validate(self):
if not self.has_share_type() and \
self.operation_type in ['sell_back', 'transfer']:
raise ValidationError(_("The cooperator doesn't own this share"
" type. Please choose the appropriate"
" share type."))
if self.operation_type in ['sell_back', 'convert', 'transfer']:
total_share_dic = self.get_total_share_dic(self.partner_id)
if self.quantity > total_share_dic[self.share_product_id.id]:
raise ValidationError(_("The cooperator can't hand over more"
" shares that he/she owns."))
if self.operation_type == 'convert':
amount_to_convert = self.share_unit_price * self.quantity
share_price = self.share_to_product_id.list_price
remainder = amount_to_convert % share_price
if remainder != 0:
raise ValidationError(_("The conversion must give a whole"
" number for quantity"))
if self.company_id.unmix_share_type:
if self.share_product_id.code == self.share_to_product_id.code:
raise ValidationError(_("You can't convert the share to"
" the same share type."))
if self.subscription_amount != self.partner_id.total_value:
raise ValidationError(_("You must convert all the shares"
" to the selected type."))
else:
if self.subscription_amount != self.partner_id.total_value:
raise ValidationError(_("Converting just part of the"
" shares is not yet implemented"))
elif self.operation_type == 'transfer':
if not self.receiver_not_member and self.company_id.unmix_share_type \
and (self.partner_id_to.cooperator_type
and self.partner_id.cooperator_type != self.partner_id_to.cooperator_type):
raise ValidationError(_("This share type could not be"
" transfered to " +
self.partner_id_to.name))
if self.partner_id_to.is_company \
and not self.share_product_id.by_company:
raise ValidationError(_("This share can not be"
" subscribed by a company"))
if not self.partner_id_to.is_company \
and not self.share_product_id.by_individual:
raise ValidationError(_("This share can not be"
" subscribed an individual"))
if self.receiver_not_member and self.subscription_request \
and not self.subscription_request.validated:
raise ValidationError(_("The information of the receiver"
" are not correct. Please correct"
" the information before"
" submitting"))
@api.multi
def execute_operation(self):
self.ensure_one()
effective_date = self.get_date_now()
sub_request = self.env['subscription.request']
for rec in self:
rec.validate()
if rec.state != 'approved':
raise ValidationError(_("This operation must be approved"
" before to be executed"))
values = {
'partner_id': rec.partner_id.id, 'quantity': rec.quantity,
'share_product_id': rec.share_product_id.id,
'type': rec.operation_type,
'share_unit_price': rec.share_unit_price,
'date': effective_date,
}
if rec.operation_type == 'sell_back':
self.hand_share_over(rec.partner_id, rec.share_product_id,
rec.quantity)
elif rec.operation_type == 'convert':
amount_to_convert = rec.share_unit_price * rec.quantity
convert_quant = int(amount_to_convert / rec.share_to_product_id.list_price)
remainder = amount_to_convert % rec.share_to_product_id.list_price
if convert_quant > 0 and remainder == 0:
share_ids = rec.partner_id.share_ids
line = share_ids[0]
if len(share_ids) > 1:
share_ids[1:len(share_ids)].unlink()
line.write({
'share_number': convert_quant,
'share_product_id': rec.share_to_product_id.id,
'share_unit_price': rec.share_to_unit_price,
'share_short_name': rec.share_to_short_name
})
values['share_to_product_id'] = rec.share_to_product_id.id
values['quantity_to'] = convert_quant
else:
raise ValidationError(_("Converting just part of the"
" shares is not yet implemented"))
elif rec.operation_type == 'transfer':
sequence_id = self.env.ref('easy_my_coop.sequence_subscription', False)
if rec.receiver_not_member:
partner = rec.subscription_request.create_coop_partner()
# get cooperator number
sub_reg_num = int(sequence_id.next_by_id())
partner_vals = sub_request.get_eater_vals(partner, rec.share_product_id)
partner_vals['member'] = True
partner_vals['cooperator_register_number'] = sub_reg_num
partner.write(partner_vals)
rec.partner_id_to = partner
else:
# means an old member or cooperator candidate
if not rec.partner_id_to.member:
if rec.partner_id_to.cooperator_register_number == 0:
sub_reg_num = int(sequence_id.next_by_id())
partner_vals['cooperator_register_number'] = sub_reg_num
partner_vals = sub_request.get_eater_vals(
rec.partner_id_to,
rec.share_product_id)
partner_vals['member'] = True
partner_vals['old_member'] = False
rec.partner_id_to.write(partner_vals)
# remove the parts to the giver
self.hand_share_over(rec.partner_id,
rec.share_product_id,
rec.quantity)
# give the share to the receiver
self.env['share.line'].create({
'share_number': rec.quantity,
'partner_id': rec.partner_id_to.id,
'share_product_id': rec.share_product_id.id,
'share_unit_price': rec.share_unit_price,
'effective_date': effective_date})
values['partner_id_to'] = rec.partner_id_to.id
else:
raise ValidationError(_("This operation is not yet"
" implemented."))
sequence_operation = self.env.ref('easy_my_coop.sequence_register_operation', False)
sub_reg_operation = sequence_operation.next_by_id()
values['name'] = sub_reg_operation
values['register_number_operation'] = int(sub_reg_operation)
rec.write({'state': 'done'})
# send mail to the receiver
if rec.operation_type == 'transfer':
certificat_email_template = self.env.ref('easy_my_coop.email_template_share_transfer', False)
certificat_email_template.send_mail(rec.partner_id_to.id, False)
self.env['subscription.register'].create(values)
certificat_email_template = self.env.ref('easy_my_coop.email_template_share_update', False)
certificat_email_template.send_mail(rec.partner_id.id, False)

42
easy_my_coop/models/partner.py

@ -59,12 +59,13 @@ class ResPartner(models.Model):
for partner, child_ids in all_partners_and_children.items():
partner.total_invoiced = sum(price['total'] for price in price_totals if price['partner_id'] in child_ids)
@api.multi
@api.model
def _get_share_type(self):
product_obj = self.env['product.product']
share_type_list = [('', '')]
for share_type in product_obj.search([('is_share', '=', True)]):
share_type_list.append((str(share_type.id), share_type.short_name))
share_type_list.append([share_type.default_code,
share_type.short_name])
return share_type_list
@api.multi
@ -76,12 +77,16 @@ class ResPartner(models.Model):
partner.effective_date = partner.share_ids[0].effective_date
@api.multi
@api.depends('share_ids')
@api.depends('share_ids', 'share_ids.share_product_id',
'share_ids.share_product_id.default_code',
'share_ids.share_number')
def _compute_cooperator_type(self):
for partner in self:
share_type = ''
for line in partner.share_ids:
share_type = str(line.share_product_id.id)
code = line.share_product_id.default_code
if code:
share_type = str(code)
if share_type != '':
partner.cooperator_type = share_type
@ -97,7 +102,7 @@ class ResPartner(models.Model):
partner.number_of_share = number_of_share
partner.total_value = total_value
cooperator = fields.Boolean(string='Cooperator',
cooperator = fields.Boolean(string='Easy My Coop',
help="Check this box if this contact is a"
" cooperator(effective or not).")
member = fields.Boolean(string='Effective cooperator',
@ -119,16 +124,16 @@ class ResPartner(models.Model):
'partner_id',
string='Share Lines')
cooperator_register_number = fields.Integer(string='Cooperator Number')
number_of_share = fields.Integer(compute="_compute_share_info",
number_of_share = fields.Integer(compute=_compute_share_info,
multi='share',
string='Number of share',
readonly=True)
total_value = fields.Float(compute="_compute_share_info",
total_value = fields.Float(compute=_compute_share_info,
multi='share',
string='Total value of shares',
readonly=True)
company_register_number = fields.Char(string='Company Register Number')
cooperator_type = fields.Selection(selection='_get_share_type',
cooperator_type = fields.Selection(selection=_get_share_type,
compute=_compute_cooperator_type,
string='Cooperator Type',
store=True)
@ -139,6 +144,19 @@ class ResPartner(models.Model):
subscription_request_ids = fields.One2many('subscription.request',
'partner_id',
string="Subscription request")
legal_form = fields.Selection([('', '')],
string="Legal form")
internal_rules_approved = fields.Boolean(string="Internal Rules Approved ")
data_policy_approved = fields.Boolean(string="Data Policy Approved ")
financial_risk_approved = fields.Boolean(string="Financial Risk Approved ")
@api.multi
def touch_cooperator_type(self):
self.ensure_one()
for line in self.share_ids:
line.share_product_id = line.share_product_id.id
break
return True
@api.multi
@api.depends('subscription_request_ids.state')
@ -162,10 +180,10 @@ class ResPartner(models.Model):
def get_representative(self):
return self.child_ids.filtered('representative')
def get_cooperator_from_nin(self, national_id_number):
def get_cooperator_from_email(self, email):
return self.search([('cooperator', '=', True),
('national_register_number', '=', national_id_number)])
('email', '=', email)])
def get_cooperator_from_crn(self, company_register_number):
def get_cooperator_from_crn(self, comp_reg_number):
return self.search([('cooperator', '=', True),
('company_register_number', '=', company_register_number)])
('company_register_number', '=', comp_reg_number)])

15
easy_my_coop/report/cooperator_certificat_G001.xml

@ -57,12 +57,17 @@
<div style="width:125px;position:relative;top:10px;border-bottom: 4pt solid #fcc300;"/>
</h2>
<div name="certificate_generation_date" style="position:relative;top:45px;">
<span> Certificate generated on </span>
<span t-esc="context_timestamp(datetime.datetime.now()).strftime('%d/%m/%Y')"/>
</div>
<div name="label_coop_number" style="position:relative;top:55px;">
<span t-field="o.name"></span>
<span> is recorded in the register of cooperators under number </span>
<span t-field="o.cooperator_register_number"></span>
</div>
<span t-field="o.cooperator_register_number"></span>
</div>
<table class="table border-easymy-coop-cert" style="position:relative;top:85px;width:90%;align:center;">
<thead class="easymy-coop-info-title">
<tr>
@ -141,7 +146,7 @@
</div>
<div class="row">
<div name="board_commitee" class="col-xs-6 pull-left" style="position:relative;top:205px;font-size:20;color:black;font-family:Roboto-Regular;">
<div name="board_commitee" class="col-xs-6 pull-left" style="position:relative;top:205px;color:black;font-family:Roboto-Regular;">
<div style="position:relative;top:205px;">
Pour le Conseil d'administration de <span t-field="o.company_id.name"/>.
</div>
@ -149,7 +154,7 @@
<strong><span t-field="o.company_id.board_representative"/></strong>
</div>
<div style="position:relative;top:225px;">
<img t-if="o.company_id.signature_scan" t-att-src="'data:image/png;base64,%s' % o.company_id.signature_scan" style="width:240px;height:200px;padding-bottom:5px;"/>
<img t-if="o.company_id.signature_scan" t-att-src="'data:image/png;base64,%s' % o.company_id.signature_scan" style="width:200px;height:150px;padding-bottom:5px;"/>
</div>
</div>
</div>

6
easy_my_coop/view/account_invoice_view.xml

@ -38,6 +38,7 @@
<record id="action_invoice_tree1_view1" model="ir.actions.act_window.view">
<field eval="1" name="sequence"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="account.invoice_tree"/>
<field name="act_window_id" ref="action_invoice_tree_coop"/>
</record>
@ -48,8 +49,7 @@
<field name="act_window_id" ref="action_invoice_tree_coop"/>
</record>
<menuitem action="action_invoice_tree_coop" id="menu_action_invoice_tree_coop" parent="menu_easy_my_coop_main_coop" groups="easy_my_coop.group_energiris_user"/>
<record id="account.action_invoice_tree1" model="ir.actions.act_window">
<field name="name">Customer Invoices</field>
<field name="res_model">account.invoice</field>
@ -85,4 +85,4 @@
<field name="search_view_id" ref="account.view_account_invoice_filter"/>
</record>
</data>
</openerp>
</openerp>

3
easy_my_coop/view/cooperator_register_view.xml

@ -75,6 +75,5 @@
<field name="search_view_id" ref="view_subscription_register_filter"/>
</record>
<menuitem action="subscription_register_action" name="Subscription Register" id="menu_easy_my_coop_subscription_register" parent="menu_easy_my_coop_main_subscription" sequence="20"/>
</data>
</openerp>
</openerp>

6
easy_my_coop/view/email_template_view.xml

@ -1,7 +1,6 @@
<openerp>
<data>
<menuitem name="Configuration" id="menu_easy_my_coop_config" parent="menu_main_easy_my_coop" sequence="20"/>
<record model="ir.actions.act_window" id="action_easy_my_coop_email_templates">
<field name="name">Mail Templates</field>
<field name="res_model">mail.template</field>
@ -11,6 +10,5 @@
<field name="search_view_id" ref="mail.view_email_template_search"/>
</record>
<menuitem id="menu_easy_my_coop_templates" parent="menu_easy_my_coop_config" action="action_easy_my_coop_email_templates" sequence="10" groups="group_energiris_manager"/>
</data>
</openerp>
</openerp>

33
easy_my_coop/view/menu.xml

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2019 Coop IT Easy
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<!-- top menus -->
<menuitem name="Easy-My Coop" id="menu_main_easy_my_coop" sequence="40" groups="easy_my_coop.group_energiris_user"/>
<menuitem name="Cooperators" id="menu_easy_my_coop_main_coop" parent="menu_main_easy_my_coop" sequence="5" />
<menuitem name="Subscription" id="menu_easy_my_coop_main_subscription" parent="menu_main_easy_my_coop" sequence="10" groups="easy_my_coop.group_energiris_manager"/>
<menuitem name="Reporting" id="menu_easy_my_coop_main_reporting" parent="menu_main_easy_my_coop" sequence="40" groups="easy_my_coop.group_energiris_manager"/>
<menuitem name="Configuration" id="menu_easy_my_coop_config" parent="menu_main_easy_my_coop" sequence="20"/>
<!-- views -->
<menuitem action="action_invoice_tree_coop" id="menu_action_invoice_tree_coop" parent="menu_easy_my_coop_main_coop" groups="easy_my_coop.group_energiris_user"/>
<menuitem id="menu_easy_my_coop_cooperator" name="Cooperators" parent="menu_easy_my_coop_main_coop" action="action_partner_cooperator_form" sequence="100"/>
<menuitem id="menu_easy_my_coop_cooperator_candidate" name="Cooperator Candidates" parent="menu_easy_my_coop_main_coop" action="action_partner_cooperator_candidate_form" sequence="150"/>
<menuitem id="menu_easy_my_coop_company_representative" name="Company representative" parent="menu_easy_my_coop_main_coop" action="action_company_representative_form" sequence="160"/>
<menuitem action="subscription_register_action" name="Subscription Register" id="menu_easy_my_coop_subscription_register" parent="menu_easy_my_coop_main_subscription" sequence="20"/>
<menuitem action="operation_request_action" name="Operation request" id="menu_easy_my_coop_operation_request" parent="menu_easy_my_coop_main_subscription" sequence="20" groups="easy_my_coop.group_energiris_manager"/>
<menuitem action="share_product_action" name="Share type" id="menu_easy_my_coop_share_product" parent="menu_easy_my_coop_main_subscription" sequence="20"/>
<menuitem action="subscription_request_action" name="Cooperator Subscription" id="menu_easy_my_coop_subscription_request" parent="menu_easy_my_coop_main_subscription" sequence="10"/>
<menuitem action="company_subscription_request_action" name="Company Subscription" id="menu_easy_my_coop_company_subscription_request" parent="menu_easy_my_coop_main_subscription" sequence="12"/>
<menuitem action="share_line_action" name="Share lines" id="menu_easy_my_coop_share_line" parent="menu_easy_my_coop_main_subscription" sequence="20" groups="group_energiris_super_manager"/>
<menuitem id="menu_easy_my_coop_templates" parent="menu_easy_my_coop_config" action="action_easy_my_coop_email_templates" sequence="10" groups="group_energiris_manager"/>
<!-- wizards -->
<menuitem action="action_view_update_partner_info" name="Update coop partner" id="menu_view_update_partner_info" parent="menu_easy_my_coop_main_subscription" sequence="60" groups="base.group_system"/>
</odoo>

8
easy_my_coop/view/menu_item_view.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<menuitem name="Easy-My Coop" id="menu_main_easy_my_coop" sequence="40" groups="easy_my_coop.group_energiris_user"/>
<menuitem name="Subscription" id="menu_easy_my_coop_main_subscription" parent="menu_main_easy_my_coop" sequence="10" groups="easy_my_coop.group_energiris_manager"/>
<menuitem name="Reporting" id="menu_easy_my_coop_main_reporting" parent="menu_main_easy_my_coop" sequence="40" groups="easy_my_coop.group_energiris_manager"/>
</data>
</odoo>

10
easy_my_coop/view/operation_request_view.xml

@ -32,7 +32,6 @@
<sheet>
<group>
<group>
<field name="state"/>
<field name="request_date" attrs="{'readonly':[('state','!=','draft')]}"/>
<field name="operation_type" attrs="{'readonly':[('state','!=','draft')]}"/>
<field name="receiver_not_member" attrs="{'invisible':[('operation_type','!=','transfer')]}"/>
@ -54,10 +53,9 @@
<field name="subscription_request" attrs="{'invisible':['|',('operation_type','!=','transfer'),('receiver_not_member','=',False)]}" context="{'default_is_operation': True, 'default_ordered_parts':quantity,'default_share_product_id': share_product_id, 'default_source':'operation'}">
<tree>
<field name="name"/>
<field name="no_registre"/>
<field name="email"/>
<field name="birthdate"/>
<field name="phone"/>
<field name="email"/>
<field name="iban"/>
<field name="state" invisible="True"/>
</tree>
@ -68,11 +66,10 @@
<field name="name"/>
<field name="firstname"/>
<field name="lastname"/>
<field name="email"/>
<field name="birthdate"/>
<field name="gender"/>
<field name="email"/>
<field name="phone"/>
<field name="no_registre"/>
<field name="iban"/>
</group>
<group>
@ -105,6 +102,5 @@
<field name="view_id" ref="operation_request_tree"/>
</record>
<menuitem action="operation_request_action" name="Operation request" id="menu_easy_my_coop_operation_request" parent="menu_easy_my_coop_main_subscription" sequence="20" groups="easy_my_coop.group_energiris_manager"/>
</data>
</openerp>
</openerp>

15
easy_my_coop/view/product_view.xml

@ -35,7 +35,17 @@
</xpath>
</field>
</record>
<record id="product_template_only_form_view" model="ir.ui.view">
<field name="name">product.template.product.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<field name="default_code" position="attributes">
<attribute name="attrs">{'required': [('is_share', '=', True)]}</attribute>
</field>
</field>
</record>
<record id="share_product_action" model="ir.actions.act_window">
<field name="name">Share type</field>
@ -54,8 +64,7 @@
</field>
</record>
<menuitem action="share_product_action" name="Share type" id="menu_easy_my_coop_share_product" parent="menu_easy_my_coop_main_subscription" sequence="20"/>
<!-- overriding product views to not display share product in the purchase and sale views-->
<record id="product.product_normal_action" model="ir.actions.act_window">

11
easy_my_coop/view/res_company_view.xml

@ -21,9 +21,18 @@
<field name="default_lang_id"/>
<field name="board_representative"/>
<field name="signature_scan"/>
<field name="display_internal_rules_approval"/>
<field name="internal_rules_approval_required"/>
<field name="internal_rules_approval_text"/>
<field name="display_data_policy_approval"/>
<field name="data_policy_approval_required"/>
<field name="data_policy_approval_text"/>
<field name="display_financial_risk_approval"/>
<field name="financial_risk_approval_required"/>
<field name="financial_risk_approval_text"/>
</group>
</xpath>
</field>
</record>
</data>
</openerp>
</openerp>

24
easy_my_coop/view/res_partner_view.xml

@ -12,17 +12,18 @@
type="action" context="{'default_active_id': active_id}" groups="easy_my_coop.group_energiris_manager"/>
<button string="Update info" name="%(action_view_update_partner_info)d"
type="action" context="{'default_active_id': active_id}" groups="easy_my_coop.group_energiris_manager"/>
<button string="Touch" name="touch_cooperator_type" type="object" groups="base.group_system"/>
</header>
</sheet>
<xpath expr="/form/sheet/group" position='before'>
<group>
<field name="representative" attrs="{'invisible':['|',('parent_id','=',False),('is_company','=',True)]}"/>
<field name="cooperator" groups="base.group_system"/>
<field name="cooperator_register_number" readonly="True" attrs="{'invisible':[('member','=',False)]}"/>
<field name="legal_form" attrs="{'invisible':[('is_company','=',False)]}"/>
<field name="company_register_number" readonly="True" attrs="{'invisible':[('is_company','=',False)]}"/>
<field name="national_register_number" readonly="True" attrs="{'invisible':[('is_company','=',True)]}" groups="easy_my_coop.group_energiris_manager"/>
<field name="coop_candidate" groups="easy_my_coop.group_energiris_user"/>
<field name="cooperator" invisible="True" groups="easy_my_coop.group_energiris_super_manager"/>
<field name="member" groups="easy_my_coop.group_energiris_super_manager"/>
<field name="cooperator_type" attrs="{'invisible':[('member','=',False)]}"/>
<field name="effective_date" attrs="{'invisible':[('member','=',False)]}"/>
@ -30,6 +31,11 @@
<group>
<field name="gender" attrs="{'invisible':[('is_company','=',True)]}"/>
</group>
<group name="approvals">
<field name="internal_rules_approved" />
<field name="data_policy_approved" />
<field name="financial_risk_approved" />
</group>
</xpath>
<xpath expr="//page[@name='sales_purchases']" position='after'>
@ -91,8 +97,7 @@
</field>
</record>
<menuitem name="Cooperators" id="menu_easy_my_coop_main_coop" parent="menu_main_easy_my_coop" sequence="5" />
<record id="action_partner_cooperator_form" model="ir.actions.act_window">
<field name="name">Cooperator</field>
<field name="type">ir.actions.act_window</field>
@ -113,8 +118,7 @@
</field>
</record>
<menuitem id="menu_easy_my_coop_cooperator" name="Cooperators" parent="menu_easy_my_coop_main_coop" action="action_partner_cooperator_form" sequence="100"/>
<record id="action_partner_cooperator_candidate_form" model="ir.actions.act_window">
<field name="name">Cooperator candidates</field>
<field name="type">ir.actions.act_window</field>
@ -135,8 +139,7 @@
</field>
</record>
<menuitem id="menu_easy_my_coop_cooperator_candidate" name="Cooperator Candidates" parent="menu_easy_my_coop_main_coop" action="action_partner_cooperator_candidate_form" sequence="150"/>
<record id="action_company_representative_form" model="ir.actions.act_window">
<field name="name">Company representative</field>
<field name="type">ir.actions.act_window</field>
@ -156,8 +159,7 @@
</field>
</record>
<menuitem id="menu_easy_my_coop_company_representative" name="Company representative" parent="menu_easy_my_coop_main_coop" action="action_company_representative_form" sequence="160"/>
<record id="remove_partner_follower" model="ir.ui.view">
<field name="name">res.partner.remove.follower.inherit</field>
<field name="model">res.partner</field>
@ -167,4 +169,4 @@
</field>
</record>
</data>
</openerp>
</openerp>

17
easy_my_coop/view/subscription_request_view.xml

@ -1,10 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<menuitem name="Easy-My Coop" id="menu_main_easy_my_coop" sequence="40" groups="easy_my_coop.group_energiris_user"/>
<menuitem name="Subscription" id="menu_easy_my_coop_main_subscription" parent="menu_main_easy_my_coop" sequence="10" groups="easy_my_coop.group_energiris_manager"/>
<menuitem name="Reporting" id="menu_easy_my_coop_main_reporting" parent="menu_main_easy_my_coop" sequence="40" groups="easy_my_coop.group_energiris_manager"/>
<record id="subscription_request_tree" model="ir.ui.view">
<field name="name">subscription.request.tree</field>
<field name="model">subscription.request</field>
@ -46,8 +42,8 @@
<field name="already_cooperator"/>
<field name="is_company" groups="easy_my_coop.group_energiris_super_manager"/>
<field name="is_operation" invisible="True"/>
<field name="company_name" attrs="{'invisible':[('is_company','=',False)]}"/>
<field name="company_email" attrs="{'invisible':[('is_company','=',False)]}"/>
<field name="company_name" attrs="{'invisible':[('is_company','=',False)],'required':[('is_company','=',True)]}"/>
<field name="company_email" attrs="{'invisible':[('is_company','=',False)],'required':[('is_company','=',True)]}"/>
<field name="company_type" attrs="{'invisible':[('is_company','=',False)]}"/>
<field name="company_register_number" attrs="{'invisible':[('is_company','=',False)]}"/>
<field name="name"/>
@ -58,7 +54,6 @@
<field name="email"/>
<field name="phone"/>
<field name="contact_person_function" attrs="{'invisible':[('is_company','=',False)]}"/>
<field name="no_registre"/>
<field name="iban"/>
<field name="address"/>
<field name="zip_code"/>
@ -79,6 +74,9 @@
<field name="lang"/>
<field name="validated"/>
<field name="skip_control_ng"/>
<field name="internal_rules_approved"/>
<field name="data_policy_approved"/>
<field name="financial_risk_approved"/>
</group>
</group>
<notebook>
@ -131,7 +129,6 @@
<field name="search_view_id" ref="view_subscription_request_filter"/>
</record>
<menuitem action="subscription_request_action" name="Cooperator Subscription" id="menu_easy_my_coop_subscription_request" parent="menu_easy_my_coop_main_subscription" sequence="10"/>
<record id="company_subscription_request_tree" model="ir.ui.view">
<field name="name">subscription.request.tree</field>
@ -168,7 +165,6 @@
<field name="search_view_id" ref="view_subscription_request_filter"/>
</record>
<menuitem action="company_subscription_request_action" name="Company Subscription" id="menu_easy_my_coop_company_subscription_request" parent="menu_easy_my_coop_main_subscription" sequence="12"/>
<record id="share_line_form" model="ir.ui.view">
<field name="name">share.line.form</field>
@ -236,6 +232,5 @@
<field name="view_type">form</field>
</record>
<menuitem action="share_line_action" name="Share lines" id="menu_easy_my_coop_share_line" parent="menu_easy_my_coop_main_subscription" sequence="20" groups="group_energiris_super_manager"/>
</data>
</openerp>
</openerp>

327
easy_my_coop/view/subscription_template.xml

@ -54,7 +54,7 @@
<h2 class="energie">Become Cooperator</h2><br/>
<div class="row">
<div class="col-md-8">
<form action="/subscription/subscribe_share" method="post" class="form-horizontal mt32" enctype="multipart/form-data">
<form method="post" class="form-horizontal mt32" enctype="multipart/form-data">
<p style="color:red;"><t t-esc="error_msg"/></p>
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
@ -69,69 +69,83 @@
Logged
</label>
</div>
<div t-attf-class="form-group">
<label>
<input type="checkbox" t-att-value="already_cooperator" name="already_cooperator" />
Already cooperator?
</label>
</div>
<div t-attf-class="form-group" style="display: none;">
Already cooperator?
<input type="checkbox"
name="already_cooperator"
t-att-checked="already_cooperator"/>
</div>
<div name="email_from_container" t-attf-class="form-group #{error and 'email_from' in error and 'has-error' or ''}">
<div name="email_container" t-attf-class="form-group #{error and 'email_from' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="email">Email</label>
<div class="col-md-7 col-sm-8 bottom-line" style="padding-bottom:20px">
<input type="email" class="form-control mandatory-field" name="email" required="True" t-attf-value="#{email or ''}" placeholder="didier.bourdon@bees-coop.be"/>
<input type="email" class="form-control mandatory-field" name="email"
required="required" t-att-readonly="logged"
t-attf-value="#{email or ''}" placeholder="didier.bourdon@bees-coop.be"/>
</div>
</div>
<div t-if="not logged" name="confirm_email_container" t-attf-class="form-group #{error and 'email_from' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="confirm_email">Confirm Email</label>
<div class="col-md-7 col-sm-8 bottom-line" style="padding-bottom:20px">
<input type="confirm_email" class="form-control mandatory-field" name="confirm_email"
required="required" t-att-readonly="logged"
t-attf-value="#{confirm_email or ''}" placeholder="didier.bourdon@bees-coop.be"/>
</div>
</div>
<div t-attf-class="form-group #{error and 'firstname' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="name">First Name</label>
<div class="col-md-7 col-sm-8" style="padding-top:5px">
<input type="text" class="form-control mandatory-field" name="firstname" required="True" t-attf-value="#{firstname or ''}" placeholder="Didier"/>
<input type="text" class="form-control mandatory-field" name="firstname"
required="required" t-att-readonly="logged"
t-attf-value="#{firstname or ''}" placeholder="Didier"/>
</div>
</div>
<div t-attf-class="form-group #{error and 'lastname' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="name">Last Name</label>
<div class="col-md-7 col-sm-8">
<input type="text" class="form-control mandatory-field" name="lastname" required="True" t-attf-value="#{lastname or ''}" placeholder="Bourdon"/>
<input type="text" class="form-control mandatory-field" name="lastname"
required="required" t-att-readonly="logged"
t-attf-value="#{lastname or ''}" placeholder="Bourdon"/>
</div>
</div>
<div t-attf-class="form-group #{error and 'gender' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="company_type">Gender</label>
<select name="gender" class="col-md-7 col-sm-8 form-control" required="True" style="width:54%;margin-left:15px">
<select name="gender" class="col-md-7 col-sm-8 form-control" required="required"
t-att-readonly="logged" style="width:54%;margin-left:15px">
<option value=""></option>
<t t-foreach="genders or []" t-as="type">
<option t-att-value="type[0]" t-att-selected="type[0] == gender"><t t-esc="type[1]"/></option>
</t>
</select>
</div>
<div t-attf-class="form-group #{error and 'birthdate' in error and 'has-error' or ''}">
<div t-attf-class="form-group #{error and 'birthdate' in error and 'has-error' or ''}" t-att-style="'display: none;' if logged else None">
<label class="col-md-3 col-sm-4 control-label" for="birthdate">Birthdate</label>
<div class="col-md-7 col-sm-8">
<input type="text" data-inputmask="'alias': 'date'" class="form-control mandatory-field" name="birthdate" required="True" t-attf-value="#{birthdate or ''}" placeholder="05/03/1978"/>
</div>
</div>
<div t-attf-class="form-group #{error and 'no_registre' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="no_registre">National Register Number</label>
<div class="col-md-7 col-sm-8">
<input type="text" class="form-control mandatory-field" name="no_registre" t-attf-value="#{no_registre or ''}" placeholder="78230226321"/>
<input type="text" data-inputmask="'alias': 'date'" class="form-control mandatory-field"
name="birthdate" required="required" t-att-readonly="logged"
t-attf-value="#{birthdate or ''}" placeholder="05/03/1978"/>
</div>
</div>
<div t-attf-class="form-group #{error and 'iban' in error and 'has-error' or ''}">
<div t-attf-class="form-group #{error and 'iban' in error and 'has-error' or ''}" t-att-style="'display: none;' if logged else None">
<label class="col-md-3 col-sm-4 control-label" for="iban">Bank Account Number</label>
<div class="col-md-7 col-sm-8">
<input type="text" class="form-control mandatory-field" name="iban" required="True" t-attf-value="#{iban or ''}" placeholder="BE48523080767127"/>
<input type="text" class="form-control mandatory-field" name="iban"
required="required" t-att-readonly="logged"
t-attf-value="#{iban or ''}" placeholder="BE48523080767127"/>
</div>
</div>
<div t-attf-class="form-group #{error and 'lang' in error and 'has-error' or ''}" >
<label class="col-md-3 col-sm-4 control-label" style="width:25%" for="lang">Language</label>
<select name="lang" class="col-md-7 col-sm-8 form-control " style="width:30%;margin-left:15px">
<select name="lang" class="col-md-7 col-sm-8 form-control" t-att-readonly="logged"
style="width:30%;margin-left:15px">
<option value="2">Language...</option>
<t t-foreach="langs or []" t-as="langue">
<option t-att-value="langue.code" t-att-selected="langue.code == lang"><t t-esc="langue.name"/></option>
@ -144,7 +158,9 @@
<div t-attf-class="form-group #{error and 'address' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="address">Address</label>
<div class="col-md-7 col-sm-8">
<input type="text" class="form-control mandatory-field" name="address" required="True" t-attf-value="#{address or ''}" placeholder="rue Van Hove, 19"/>
<input type="text" class="form-control mandatory-field" name="address"
required="required" t-att-readonly="logged"
t-attf-value="#{address or ''}" placeholder="rue Van Hove, 19"/>
</div>
</div>
@ -154,12 +170,16 @@
<table>
<tr>
<td width="20%">
<input type="text" class="form-control mandatory-field" name="zip_code" required="True" t-attf-value="#{zip_code or ''}" placeholder="1030"/>
<input type="text" class="form-control mandatory-field" name="zip_code"
required="required" t-att-readonly="logged"
t-attf-value="#{zip_code or ''}" placeholder="1030"/>
</td>
<td width="3%"></td>
<td>
<input type="text" class="form-control mandatory-field" name="city" required="True" t-attf-value="#{city or ''}" placeholder="Bruxelles"/>
</td>
<input type="text" class="form-control mandatory-field" name="city"
required="required" t-att-readonly="logged"
t-attf-value="#{city or ''}" placeholder="Bruxelles"/>
</td>
</tr>
</table>
</div>
@ -167,7 +187,8 @@
<div t-attf-class="form-group #{error and 'country_id' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" style="width:25%" for="country_id">Country</label>
<select name="country_id" class="col-md-7 col-sm-8 form-control " style="width:54%;margin-left:15px">
<select name="country_id" class="col-md-7 col-sm-8 form-control " t-att-readonly="logged"
style="width:54%;margin-left:15px">
<option value="">Country...</option>
<t t-foreach="countries or []" t-as="country">
<option t-att-value="country.id" t-att-selected="country.id == int(country_id)"><t t-esc="country.name"/></option>
@ -178,7 +199,9 @@
<div t-attf-class="form-group #{error and 'phone' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="phone">Phone</label>
<div class="col-md-7 col-sm-8 bottom-line" style="padding-bottom:20px">
<input type="text" class="form-control" name="phone" required="True" t-attf-value="#{phone or ''}" placeholder="e.g. (+32).81.81.37.00"/>
<input type="text" class="form-control" name="phone"
required="required" t-att-readonly="logged"
t-attf-value="#{phone or ''}" placeholder="e.g. (+32).81.81.37.00"/>
</div>
</div>
@ -219,7 +242,7 @@
<td width="20%">
<div style="margin-top:12px" t-attf-class="form-group #{error and 'total_parts' in error and 'has-error' or ''}">
<div>
<input type="text" class="form-control total" name="total_parts" value="25" data-max="5000"
<input type="text" class="form-control total" name="total_parts" value="25" t-att-data-max="company.subscription_maximum_amount"
t-att-readonly="'readonly'"
/>
</div>
@ -236,14 +259,59 @@
</div>
</div>
<div class="bottom-line" style="margin-left:178px;margin-top:0px;width:61%"></div>
<div class="bottom-line" style="margin-left:178px;margin-top:0px;width:61%"></div>
<br/>
<div id="internal_rules_approved" t-if="display_internal_rules" t-attf-class="form-group" >
<label class="col-md-3 col-sm-4 control-label" for="internal_rules_approved">Internal Rules</label>
<div class="col-md-9 col-sm-8">
<div class="checkbox">
<label>
<input type="checkbox"
name="internal_rules_approved"
t-att-required="internal_rules_required"
t-att-checked="internal_rules_approved"/>
<t t-raw="internal_rules_text"/>
</label>
</div>
</div>
</div>
<div id="data_policy_approved" t-if="display_data_policy" t-attf-class="form-group" >
<label class="col-md-3 col-sm-4 control-label" for="data_policy_approved">Privacy Policy</label>
<div class="col-md-9 col-sm-8">
<div class="checkbox">
<label>
<input type="checkbox"
name="data_policy_approved"
t-att-required="data_policy_required"
t-att-checked="data_policy_approved"/>
<t t-raw="data_policy_text"/>
</label>
</div>
</div>
</div>
<div id="financial_risk_approved" t-if="display_financial_risk" t-attf-class="form-group" >
<label class="col-md-3 col-sm-4 control-label" for="financial_risk_approved">Financial Risk</label>
<div class="col-md-9 col-sm-8">
<div class="checkbox">
<label>
<input type="checkbox"
name="financial_risk_approved"
t-att-required="financial_risk_required"
t-att-checked="financial_risk_approved"/>
<t t-raw="financial_risk_text"/>
</label>
</div>
</div>
</div>
<table style="margin-left:195px">
<tr>
<td width="80%">
<div class="g-recaptcha" t-att-data-sitekey="website.recaptcha_site_key" data-theme="green"/><br/>
<div class="g-recaptcha" t-att-data-sitekey="website.recaptcha_site_key" data-theme="green"/><br/>
</td>
<td>
<div class="form-group">
@ -251,7 +319,7 @@
<button class="btn btn-primary btn-lg">Send</button>
</div>
</div>
</td>
</td>
</tr>
</table>
@ -273,7 +341,7 @@
<h2 class="energie">Become Cooperator</h2><br/>
<div class="row">
<div class="col-md-8">
<form action="/subscription/subscribe_share" method="post" class="form-horizontal mt32" enctype="multipart/form-data">
<form method="post" class="form-horizontal mt32" enctype="multipart/form-data">
<p style="color:red;"><t t-esc="error_msg"/></p>
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
@ -286,6 +354,12 @@
<input type="checkbox" t-att-value="is_company" checked="checked" name="is_company" />
Is a company?
</label>
<label>
Already cooperator?
<input type="checkbox"
name="already_cooperator"
t-att-checked="already_cooperator"/>
</label>
</div>
<div t-attf-class="form-group">
@ -297,20 +371,25 @@
<div t-attf-class="form-group #{error and 'company_register_number' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="company_register_number">Company Register Number</label>
<div class="col-md-7 col-sm-8">
<input type="text" class="form-control mandatory-field" name="company_register_number" required="True" t-attf-value="#{company_register_number or ''}" placeholder="0647980091"/>
<input type="text" class="form-control mandatory-field" name="company_register_number"
required="required" t-att-readonly="logged"
t-attf-value="#{company_register_number or ''}" placeholder="0647980091"/>
</div>
</div>
<div t-attf-class="form-group #{error and 'company_name' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="company_name">Company name</label>
<div class="col-md-7 col-sm-8">
<input type="text" class="form-control mandatory-field" name="company_name" required="True" t-attf-value="#{company_name or ''}" placeholder="La super coopérative"/>
<input type="text" class="form-control mandatory-field" name="company_name"
required="required" t-att-readonly="logged"
t-attf-value="#{company_name or ''}" placeholder="La super coopérative"/>
</div>
</div>
<div t-attf-class="form-group #{error and 'company_type' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="company_type">Company type</label>
<select name="company_type" class="col-md-7 col-sm-8 form-control" required="True" style="width:54%;margin-left:15px">
<select name="company_type" class="col-md-7 col-sm-8 form-control"
required="required" t-att-readonly="logged" style="width:54%;margin-left:15px">
<option value=""></option>
<t t-foreach="company_types or []" t-as="type">
<option t-att-value="type[0]" t-att-selected="type[0] == company_type"><t t-esc="type[1]"/></option>
@ -321,14 +400,26 @@
<div t-attf-class="form-group #{error and 'company_email' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="company_email">Company email</label>
<div class="col-md-7 col-sm-8">
<input type="text" class="form-control mandatory-field" name="company_email" required="True" t-attf-value="#{company_email or ''}" placeholder="administration@beescoop.be"/>
<input type="text" class="form-control mandatory-field" name="company_email"
required="required" t-att-readonly="logged"
t-attf-value="#{company_email or ''}" placeholder="administration@beescoop.be"/>
</div>
</div>
<div t-attf-class="form-group #{error and 'email_from' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="confirm_email">Confirm Email</label>
<div class="col-md-7 col-sm-8 bottom-line" style="padding-bottom:20px">
<input type="confirm_email" class="form-control mandatory-field" name="confirm_email"
required="required" t-att-readonly="logged"
t-attf-value="#{confirm_email or ''}" placeholder="didier.bourdon@bees-coop.be"/>
</div>
</div>
<div t-attf-class="form-group #{error and 'iban' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="iban">Bank Account Number</label>
<div class="col-md-7 col-sm-8">
<input type="text" class="form-control mandatory-field" name="iban" required="True" t-attf-value="#{iban or ''}" placeholder="BE48523080767127"/>
<input type="text" class="form-control mandatory-field" name="iban"
required="required" t-att-readonly="logged"
t-attf-value="#{iban or ''}" placeholder="BE48523080767127"/>
</div>
</div>
@ -342,7 +433,9 @@
<div t-attf-class="form-group #{error and 'address' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="address">Address</label>
<div class="col-md-7 col-sm-8">
<input type="text" class="form-control mandatory-field" name="address" required="True" t-attf-value="#{address or ''}" placeholder="rue Van Hove, 19"/>
<input type="text" class="form-control mandatory-field" name="address"
required="required" t-att-readonly="logged"
t-attf-value="#{address or ''}" placeholder="rue Van Hove, 19"/>
</div>
</div>
@ -352,11 +445,15 @@
<table>
<tr>
<td width="20%">
<input type="text" class="form-control mandatory-field" name="zip_code" required="True" t-attf-value="#{zip_code or ''}" placeholder="1030"/>
<input type="text" class="form-control mandatory-field" name="zip_code"
required="required" t-att-readonly="logged"
t-attf-value="#{zip_code or ''}" placeholder="1030"/>
</td>
<td width="3%"></td>
<td>
<input type="text" class="form-control mandatory-field" name="city" required="True" t-attf-value="#{city or ''}" placeholder="Bruxelles"/>
<input type="text" class="form-control mandatory-field" name="city"
required="required" t-att-readonly="logged"
t-attf-value="#{city or ''}" placeholder="Bruxelles"/>
</td>
</tr>
</table>
@ -366,7 +463,8 @@
<div t-attf-class="form-group #{error and 'country_id' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" style="width:25%" for="country_id">Country</label>
<select name="country_id" class="col-md-7 col-sm-8 form-control" style="width:54%;margin-left:15px">
<select name="country_id" class="col-md-7 col-sm-8 form-control" t-att-readonly="logged"
style="width:54%;margin-left:15px">
<option value="">Country...</option>
<t t-foreach="countries or []" t-as="country">
<option t-att-value="country.id" t-att-selected="country.id == int(country_id)"><t t-esc="country.name"/></option>
@ -383,20 +481,25 @@
<div t-attf-class="form-group #{error and 'firstname' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="firstname">First Name</label>
<div class="col-md-7 col-sm-8" style="padding-top:5px">
<input type="text" class="form-control mandatory-field" name="firstname" required="True" t-attf-value="#{firstname or ''}" placeholder="Didier"/>
<input type="text" class="form-control mandatory-field" name="firstname"
required="required" t-att-readonly="logged"
t-attf-value="#{firstname or ''}" placeholder="Didier"/>
</div>
</div>
<div t-attf-class="form-group #{error and 'lastname' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="lastname">Last Name</label>
<div class="col-md-7 col-sm-8">
<input type="text" class="form-control mandatory-field" name="lastname" required="True" t-attf-value="#{lastname or ''}" placeholder="Bourdon"/>
<input type="text" class="form-control mandatory-field" name="lastname"
required="required" t-att-readonly="logged"
t-attf-value="#{lastname or ''}" placeholder="Bourdon"/>
</div>
</div>
<div t-attf-class="form-group #{error and 'gender' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="gender">Gender</label>
<select name="gender" class="col-md-7 col-sm-8 form-control" required="True" style="width:54%;margin-left:15px">
<select name="gender" class="col-md-7 col-sm-8 form-control"
required="required" t-att-readonly="logged" style="width:54%;margin-left:15px">
<option value=""></option>
<t t-foreach="genders or []" t-as="type">
<option t-att-value="type[0]" t-att-selected="type[0] == gender"><t t-esc="type[1]"/></option>
@ -407,42 +510,44 @@
<div name="email_from_container" t-attf-class="form-group #{error and 'email_from' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="email">Email</label>
<div class="col-md-7 col-sm-8 bottom-line" style="padding-bottom:20px">
<input type="email" class="form-control mandatory-field" name="email" required="True" t-attf-value="#{email or ''}" placeholder="didier.bourdon@bees-coop.be"/>
<input type="email" class="form-control mandatory-field" name="email"
required="required" t-att-readonly="logged"
t-attf-value="#{email or ''}" placeholder="didier.bourdon@bees-coop.be"/>
</div>
</div>
<div t-attf-class="form-group #{error and 'phone' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="phone">Phone</label>
<div class="col-md-7 col-sm-8 bottom-line" style="padding-bottom:20px">
<input type="text" class="form-control" name="phone" required="True" t-attf-value="#{phone or ''}" placeholder="e.g. (+32).81.81.37.00"/>
<input type="text" class="form-control" name="phone"
required="required" t-att-readonly="logged"
t-attf-value="#{phone or ''}" placeholder="e.g. (+32).81.81.37.00"/>
</div>
</div>
<div t-attf-class="form-group #{error and 'contact_person_function' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="contact_person_function">Function</label>
<div class="col-md-7 col-sm-8">
<input type="text" class="form-control mandatory-field" name="contact_person_function" required="True" t-attf-value="#{contact_person_function or ''}"/>
<input type="text" class="form-control mandatory-field" name="contact_person_function"
required="required" t-att-readonly="logged"
t-attf-value="#{contact_person_function or ''}"/>
</div>
</div>
<div t-attf-class="form-group #{error and 'no_registre' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="no_registre">National Register Number</label>
<div class="col-md-7 col-sm-8">
<input type="text" class="form-control mandatory-field" name="no_registre" required="True" t-attf-value="#{no_registre or ''}" placeholder="78230226321"/>
</div>
</div>
<div t-attf-class="form-group #{error and 'birthday' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="birthdate">Birthdate</label>
<div class="col-md-7 col-sm-8">
<input type="text" data-inputmask="'alias': 'date'" class="form-control mandatory-field" name="birthdate" required="True" t-attf-value="#{birthdate or ''}" placeholder="05/03/1978"/>
<input type="text" data-inputmask="'alias': 'date'" class="form-control mandatory-field"
name="birthdate" required="required" t-att-readonly="logged"
t-attf-value="#{birthdate or ''}" placeholder="05/03/1978"/>
</div>
</div>
<div t-attf-class="form-group #{error and 'lang' in error and 'has-error' or ''}" >
<label class="col-md-3 col-sm-4 control-label" style="width:25%" for="lang">Language</label>
<select name="lang" class="col-md-7 col-sm-8 form-control " style="width:30%;margin-left:15px">
<select name="lang" class="col-md-7 col-sm-8 form-control "
t-att-readonly="logged" style="width:30%;margin-left:15px">
<option value="2">Language...</option>
<t t-foreach="langs or []" t-as="langue">
<option t-att-value="langue.code" t-att-selected="langue.code == lang"><t t-esc="langue.name"/></option>
@ -455,7 +560,8 @@
<div t-attf-class="form-group #{error and 'product_id' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" style="width:25%" for="share_product_id">Parts type</label>
<select id="share_product_id" name="share_product_id" class="col-md-7 col-sm-8 form-control " style="width:54%;margin-left:15px">
<select id="share_product_id" name="share_product_id" class="col-md-7 col-sm-8 form-control "
t-att-readonly="logged" style="width:54%;margin-left:15px">
<t t-foreach="products or []" t-as="product">
<option t-att-value="product.id" t-att-selected="product.id == int(share_product_id)"><t t-esc="product.short_name"/></option>
</t>
@ -490,32 +596,81 @@
<div style="margin-top:12px" t-attf-class="form-group #{error and 'total_parts' in error and 'has-error' or ''}">
<div>
<input type="text" class="form-control total" name="total_parts" value="25" data-max="5000"
t-att-readonly="'readonly'"
t-att-readonly="'readonly'"
/>
</div>
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
<div class="bottom-line" style="margin-left:178px;margin-top:0px;width:61%"></div>
<div class="bottom-line" style="margin-left:178px;margin-top:0px;width:61%"></div>
<br/>
<table style="margin-left:195px">
<tr>
<td width="80%">
<div class="g-recaptcha" t-att-data-sitekey="website.recaptcha_site_key" data-theme="green"/><br/>
</td>
<td>
<div class="form-group">
<div class="col-md-offset-3 col-sm-offset-4 col-sm-8 col-md-7">
<button class="btn btn-primary btn-lg">Send</button>
</div>
</div>
</td>
</tr>
</table>
<div id="internal_rules_approved" t-if="display_internal_rules" t-attf-class="form-group" >
<label class="col-md-3 col-sm-4 control-label" for="internal_rules_approved">Internal Rules</label>
<div class="col-md-9 col-sm-8">
<div class="checkbox">
<label>
<input type="checkbox"
name="internal_rules_approved"
t-att-required="internal_rules_required"
t-att-checked="internal_rules_approved"/>
<t t-raw="internal_rules_text"/>
</label>
</div>
</div>
</div>
<div id="data_policy_approved" t-if="display_data_policy" t-attf-class="form-group" >
<label class="col-md-3 col-sm-4 control-label" for="data_policy_approved">Privacy Policy</label>
<div class="col-md-9 col-sm-8">
<div class="checkbox">
<label>
<input type="checkbox"
name="data_policy_approved"
t-att-required="data_policy_required"
t-att-checked="data_policy_approved"/>
<t t-raw="data_policy_text"/>
</label>
</div>
</div>
</div>
<div id="financial_risk_approved" t-if="display_financial_risk" t-attf-class="form-group" >
<label class="col-md-3 col-sm-4 control-label" for="financial_risk_approved">Financial Risk</label>
<div class="col-md-9 col-sm-8">
<div class="checkbox">
<label>
<input type="checkbox"
name="financial_risk_approved"
t-att-required="financial_risk_required"
t-att-checked="financial_risk_approved"/>
<t t-raw="financial_risk_text"/>
</label>
</div>
</div>
</div>
<div t-attf-class="form-group" >
<div class="col-md-7 col-sm-8">
<table style="margin-left:195px">
<tr>
<td width="80%">
<div class="g-recaptcha" t-att-data-sitekey="website.recaptcha_site_key" data-theme="green"/><br/>
</td>
<td>
<div class="form-group">
<div class="col-md-offset-3 col-sm-offset-4 col-sm-8 col-md-7">
<button class="btn btn-primary btn-lg">Send</button>
</div>
</div>
</td>
</tr>
</table>
</div>
</div>
<br/>
</form>

41
easy_my_coop/wizard/cooperative_history_wizard.xml

@ -1,41 +0,0 @@
<?xml version="1.0" ?>
<openerp>
<data>
<record id="view_cooperative_history_wizard" model="ir.ui.view">
<field name="name">cooperative.history.wizard.form</field>
<field name="model">cooperative.history.report</field>
<field name="arch" type="xml">
<form string="Reporting" version="7.0">
<separator string="Cooperative History"/>
<group>
<field name="report"/>
</group>
<label string="This report allows you to print a pdf of history and number of share for each cooperator"/>
<group>
<field name="display_cooperator"/>
</group>
<footer>
<button name="check_report" string="Print" type="object" default_focus="1" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
<record id="action_cooperative_history_wizard" model="ir.actions.act_window">
<field name="name">Cooperative history</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">cooperative.history.report</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_cooperative_history_wizard"/>
<field name="target">new</field>
<field name="multi">True</field>
</record>
<menuitem id="menu_energiris_reporting" name="Reporting" parent="menu_main_energiris" sequence="20"/>
<menuitem id="menu_coop_history_wizard_report" name="Cooperative history report" parent="menu_energiris_reporting" action="action_cooperative_history_wizard" sequence="10"/>
</data>
</openerp>

41
easy_my_coop/wizard/create_subscription_from_partner.py

@ -30,15 +30,15 @@ class PartnerCreateSubscription(models.TransientModel):
def _get_representative(self):
partner = self._get_partner()
if partner.is_company:
return self.env['res.partner'].search([('parent_id', '=', partner.id),
('representative', '=', True)])
return partner.search([('parent_id', '=', partner.id),
('representative', '=', True)])
return False
@api.model
def _get_representative_number(self):
def _get_representative_email(self):
representative = self._get_representative()
if representative:
return representative.national_register_number
return representative.email
return False
@api.model
@ -67,8 +67,6 @@ class PartnerCreateSubscription(models.TransientModel):
partner = self._get_partner()
if partner.is_company:
return partner.company_register_number
else:
return partner.national_register_number
@api.model
def _get_bank_account(self):
@ -101,8 +99,7 @@ class PartnerCreateSubscription(models.TransientModel):
cooperator = fields.Many2one('res.partner',
string="Cooperator",
default=_get_partner)
register_number = fields.Char(string="Register Number",
required=True,
register_number = fields.Char(string="Register Company Number",
default=_get_register_number)
email = fields.Char(string="Email",
required=True,
@ -126,16 +123,8 @@ class PartnerCreateSubscription(models.TransientModel):
readonly=True)
representative_name = fields.Char(string='Representative name',
default=_get_representative_name)
representative_number = fields.Char(string='Representative national '
'register number',
default=_get_representative_number)
def check_belgian_ident_id(self, register_number):
sub_req = self.env['subscription.request']
if sub_req.check_belgian_identification_id(register_number):
return True
else:
raise UserError(_("The national register number is not valid."))
representative_email = fields.Char(string='Representative email',
default=_get_representative_email)
@api.multi
def create_subscription(self):
@ -144,6 +133,7 @@ class PartnerCreateSubscription(models.TransientModel):
cooperator = self.cooperator
vals = {'partner_id': cooperator.id,
'cooperator': True,
'share_product_id': self.share_product.id,
'ordered_parts': self.share_qty,
'user_id': self.env.uid,
@ -163,7 +153,6 @@ class PartnerCreateSubscription(models.TransientModel):
vals['is_company'] = True
else:
vals['name'] = cooperator.name
vals['no_registre'] = self.register_number
coop_vals = {}
if not self._get_email():
@ -172,15 +161,12 @@ class PartnerCreateSubscription(models.TransientModel):
if not self._get_register_number():
if self.is_company:
coop_vals['company_register_number'] = self.register_number
else:
if self.check_belgian_ident_id(self.register_number):
coop_vals['national_register_number'] = self.register_number
if self.is_company and not self._get_representative():
representative = False
if self.representative_number:
representative_number = self.representative_number
representative = partner_obj.search([('national_register_number', '=', representative_number)])
if self.representative_email:
representative = partner_obj.search(
[('email', '=', self.representative_email)])
if representative:
if len(representative) > 1:
@ -193,10 +179,10 @@ class PartnerCreateSubscription(models.TransientModel):
"two different companies."))
representative.parent_id = cooperator.id
else:
if self.check_belgian_ident_id(representative_number):
if self.representative_email:
represent_vals = {'name': self.representative_name,
'cooperator': True,
'national_register_number': representative_number,
'email': self.representative_email,
'parent_id': cooperator.id,
'representative': True}
partner_obj.create(represent_vals)
@ -209,7 +195,6 @@ class PartnerCreateSubscription(models.TransientModel):
if self.is_company:
representative = self._get_representative()
vals['name'] = representative.name
vals['no_registre'] = representative.national_register_number
if coop_vals:
cooperator.write(coop_vals)

2
easy_my_coop/wizard/create_subscription_from_partner.xml

@ -13,7 +13,7 @@
<field name="is_company" invisible="True"/>
<field name="cooperator" invisible="True"/>
<field name="representative_name" attrs="{'invisible':[('is_company','=',False)],'required':[('is_company','=',True)]}"/>
<field name="representative_number" attrs="{'invisible':[('is_company','=',False)],'required':[('is_company','=',True)]}"/>
<field name="representative_email" attrs="{'invisible':[('is_company','=',False)],'required':[('is_company','=',True)]}"/>
<field name="email"/>
<field name="register_number"/>
<field name="bank_account"/>

58
easy_my_coop/wizard/update_partner_info.py

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
from openerp import api, fields, models, _
from openerp.exceptions import UserError
from openerp import api, fields, models
class PartnerUpdateInfo(models.TransientModel):
@ -18,36 +17,55 @@ class PartnerUpdateInfo(models.TransientModel):
partner = self._get_partner()
if partner.is_company:
return partner.company_register_number
else:
return partner.national_register_number
register_number = fields.Char(string="Register Number",
required=True,
default=_get_register_number)
cooperator = fields.Many2one('res.partner',
string="Cooperator",
default=_get_partner)
def check_belgian_ident_id(self, register_number):
if self.env['subscription.request'].check_belgian_identification_id(
register_number):
return True
else:
raise UserError(_("The national register number is not valid."))
all = fields.Boolean(string="Update from subscription request")
birthdate = fields.Boolean(string="set missing birth date")
legal_form = fields.Boolean(string="Set legal form")
representative_function = fields.Boolean(string="Set function")
@api.multi
def update(self):
partner_obj = self.env['res.partner']
cooperator = self.cooperator
coop_vals = {}
if cooperator.is_company:
coop_vals['company_register_number'] = self.register_number
if self.all:
if self.legal_form or self.representative_function:
coops = partner_obj.search([('cooperator', '=', True),
('is_company', '=', True)])
for coop in coops:
coop_vals = {}
sub_reqs = coop.subscription_request_ids.filtered(lambda r: r.state in ['done', 'paid'])
if sub_reqs:
sub_req = sub_reqs[0]
if self.legal_form:
coop_vals['legal_form'] = sub_req.company_type
coop.write(coop_vals)
if self.representative_function:
contact = coop.get_representative()
contact.function = sub_req.contact_person_function
else:
coops = partner_obj.search([('cooperator', '=', True),
('birthdate_date', '=', False),
('is_company', '=', False)])
for coop in coops:
coop_vals = {}
sub_reqs = coop.subscription_request_ids.filtered(lambda r: r.state in ['done', 'paid'])
if sub_reqs:
sub_req = sub_reqs[0]
if self.birthdate:
coop_vals['birthdate_date'] = sub_req.birthdate
coop.write(coop_vals)
else:
if self.check_belgian_ident_id(self.register_number):
coop_vals['national_register_number'] = self.register_number
if coop_vals:
cooperator.write(coop_vals)
if cooperator:
if cooperator.is_company:
coop_vals['company_register_number'] = self.register_number
if coop_vals:
cooperator.write(coop_vals)
return True

7
easy_my_coop/wizard/update_partner_info.xml

@ -10,8 +10,12 @@
Update Cooperator Info.
</p>
<group>
<field name="all"/>
<field name="birthdate"/>
<field name="legal_form"/>
<field name="representative_function"/>
<field name="cooperator" readonly="True"/>
<field name="register_number"/>
<field name="register_number" attrs="{'required':[('all', '=', False)]}"/>
</group>
<footer>
<button name="update" string="Update Info" type="object" class="btn-primary"/>
@ -30,6 +34,5 @@
<field name="target">new</field>
<field name="groups_id" eval="[(4,ref('easy_my_coop.group_energiris_manager'))]"/>
</record>
</data>
</openerp>

1
easy_my_coop/wizard/update_share_line.py

@ -29,7 +29,6 @@ class ShareLineUpdateInfo(models.TransientModel):
@api.multi
def update(self):
line = self.share_line
cooperator = line.partner_id

1
easy_my_coop_be/__init__.py

@ -0,0 +1 @@
from . import models

2
easy_my_coop_be/models/__init__.py

@ -0,0 +1,2 @@
from . import coop
from . import partner

11
easy_my_coop_be/models/coop.py

@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
from openerp import fields, models
class SubscriptionRequest(models.Model):
_inherit = 'subscription.request'
company_type = fields.Selection([('scrl', 'SCRL'),
('asbl', 'ASBL'),
('sprl', 'SPRL'),
('sa', 'SA')])

11
easy_my_coop_be/models/partner.py

@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
from openerp import fields, models
class ResPartner(models.Model):
_inherit = 'res.partner'
legal_form = fields.Selection(selection_add=[('scrl', 'SCRL'),
('asbl', 'ASBL'),
('sprl', 'SPRL'),
('sa', 'SA')])

1
easy_my_coop_ch/__openerp__.py

@ -32,7 +32,6 @@
""",
'data': [
'views/subscription_template.xml',
'views/subscription_request_view.xml'
],
'installable': True,
}

3
easy_my_coop_ch/models/__init__.py

@ -1 +1,2 @@
from . import coop
from . import coop
from . import partner

27
easy_my_coop_ch/models/coop.py

@ -5,22 +5,25 @@ from openerp import fields, models
class subscription_request(models.Model):
_inherit = 'subscription.request'
company_type = fields.Selection([('ei', 'Individual company'),
('snc', 'Partnership'),
('sa', 'Limited company (SA)'),
('sarl', 'Limited liability company (Ltd)'), #noqa
('sc', 'Cooperative'),
('asso', 'Association'),
('fond', 'Foundation'),
('edp', 'Company under public law')])
company_type = fields.Selection(selection_add=[
('ei', 'Individual company'),
('snc', 'Partnership'),
('sa', 'Limited company (SA)'),
('sarl', 'Limited liability company (Ltd)'),
('sc', 'Cooperative'),
('asso', 'Association'),
('fond', 'Foundation'),
('edp', 'Company under public law')
])
def get_required_field(self):
req_fields = super(subscription_request, self).get_required_field()
if 'no_registre' in req_fields:
req_fields.remove('no_registre')
if 'iban' in req_fields:
req_fields.remove('iban')
return req_fields
def check_belgian_identification_id(self, nat_register_num):
# deactivate number validation for swiss localization
def check_iban(self, iban):
if iban:
return super(subscription_request, self).check_iban(iban)
return True

17
easy_my_coop_ch/models/partner.py

@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
from openerp import fields, models
class ResPartner(models.Model):
_inherit = 'res.partner'
legal_form = fields.Selection(selection_add=[
('ei', 'Individual company'),
('snc', 'Partnership'),
('sa', 'Limited company (SA)'),
('sarl', 'Limited liability company (Ltd)'),
('sc', 'Cooperative'),
('asso', 'Association'),
('fond', 'Foundation'),
('edp', 'Company under public law')
])

13
easy_my_coop_ch/views/subscription_request_view.xml

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="subscription_request_form" model="ir.ui.view">
<field name="name">subscription.request.form</field>
<field name="model">subscription.request</field>
<field name="inherit_id" ref="easy_my_coop.subscription_request_form"/>
<field name="arch" type="xml">
<field name="no_registre" position="replace"/>
</field>
</record>
</data>
</odoo>

18
easy_my_coop_ch/views/subscription_template.xml

@ -2,11 +2,25 @@
<odoo>
<data>
<template id="subscription_i18n_ch" inherit_id="easy_my_coop.becomecooperator" name="Removing fields">
<xpath expr="//label[@for='no_registre']/.." position="replace"/>
<xpath expr="//label[@for='iban']/.." position="replace">
<div t-attf-class="form-group #{error and 'iban' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="iban">Bank Account Number</label>
<div class="col-md-7 col-sm-8">
<input type="text" class="form-control mandatory-field" name="iban" t-attf-value="#{iban or ''}" placeholder="BE48523080767127"/>
</div>
</div>
</xpath>
</template>
<template id="company_subscription_i18n_ch" inherit_id="easy_my_coop.becomecompanycooperator" name="Company Removing fields">
<xpath expr="//label[@for='no_registre']/.." position="replace"/>
<xpath expr="//label[@for='iban']/.." position="replace">
<div t-attf-class="form-group #{error and 'iban' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="iban">Bank Account Number</label>
<div class="col-md-7 col-sm-8">
<input type="text" class="form-control mandatory-field" name="iban" t-attf-value="#{iban or ''}" placeholder="BE48523080767127"/>
</div>
</div>
</xpath>
</template>
</data>
</odoo>

3
easy_my_coop_eater/__openerp__.py

@ -31,5 +31,8 @@
'data': [
'view/product_view.xml',
],
'demo': [
'demo/eaters.xml',
],
'installable': True,
}

28
easy_my_coop_eater/demo/eaters.xml

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2019 Coop IT Easy
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="easy_my_coop.res_partner_cooperator_2_demo" model="res.partner">
<field name="eater">worker_eater</field>
</record>
<record id="easy_my_coop.res_partner_cooperator_3_demo" model="res.partner">
<field name="eater">worker_eater</field>
</record>
<record id="easy_my_coop.res_partner_cooperator_4_demo" model="res.partner">
<field name="eater">worker_eater</field>
</record>
<record id="easy_my_coop.res_partner_cooperator_5_demo" model="res.partner">
<field name="eater">worker_eater</field>
</record>
<record id="easy_my_coop.res_partner_cooperator_6_demo" model="res.partner">
<field name="eater">worker_eater</field>
</record>
</odoo>

14
easy_my_coop_export_xlsx/wizard/export_global_wizard.py

@ -10,7 +10,6 @@ import xlsxwriter
HEADER = [
'Num. Coop',
'Numero de registre national',
'Nom',
'Email',
'Banque',
@ -22,8 +21,6 @@ HEADER = [
'Pays',
'Nombre de part total',
'Montant total des parts',
# 'Numero de demande',
# 'Statut',
'Demande de liberation de capital',
'Communication',
'Nombre de part',
@ -38,7 +35,6 @@ HEADER2 = [
'Nombre de part',
'Montant',
'Statut',
'Numero de registre national',
'Email',
'Mobile',
'Adresse',
@ -79,8 +75,6 @@ class export_global_report(models.TransientModel):
i = 0
worksheet1.write(j, i, coop.cooperator_register_number)
i += 1
worksheet1.write(j, i, coop.national_register_number)
i += 1
worksheet1.write(j, i, coop.name)
i += 1
worksheet1.write(j, i, coop.email)
@ -126,8 +120,8 @@ class export_global_report(models.TransientModel):
i += 1
worksheet1.write(j, i, line.price_subtotal)
i += 1
if invoice.payment_ids:
worksheet1.write(j, i, invoice.payment_ids[0].date)
if invoice.payment_move_line_ids:
worksheet1.write(j, i, invoice.payment_move_line_ids[0].date)
i += 1
if invoice.subscription_request:
ind = len(invoice.subscription_request)-1
@ -225,7 +219,7 @@ class export_global_report(models.TransientModel):
amount = quantity * sub_request.share_unit_price
worksheet1bis.write(j, i, amount)
i += 2
worksheet1bis.write(j, i, sub_request.sync_date)
worksheet1bis.write(j, i, sub_request.date)
j += 1
worksheet2 = workbook.add_worksheet()
@ -252,8 +246,6 @@ class export_global_report(models.TransientModel):
i += 1
worksheet2.write(j, i, sub_request.state)
i += 1
worksheet2.write(j, i, sub_request.no_registre)
i += 1
worksheet2.write(j, i, sub_request.email)
i += 1
worksheet2.write(j, i, sub_request.phone)

1
easy_my_coop_fr/models/__init__.py

@ -1 +1,2 @@
from . import coop
from . import partner

10
easy_my_coop_fr/models/coop.py

@ -5,11 +5,12 @@ from openerp import fields, models
class SubscriptionRequest(models.Model):
_inherit = 'subscription.request'
company_type = fields.Selection([
company_type = fields.Selection(selection_add=[
('asso', 'Association'),
('eurl', 'EURL / Entreprise individuelle'),
('sarl', 'SARL'),
('sa', 'SA / SAS')])
('sa', 'SA / SAS')
])
def get_required_field(self):
req_fields = super(SubscriptionRequest, self).get_required_field()
@ -17,8 +18,3 @@ class SubscriptionRequest(models.Model):
req_fields.remove('iban')
return req_fields
# override function to disable the check
def check_belgian_identification_id(self, nat_register_num):
# deactivate number validation for french localization
return True

13
easy_my_coop_fr/models/partner.py

@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
from openerp import fields, models
class ResPartner(models.Model):
_inherit = 'res.partner'
legal_form = fields.Selection(selection_add=[
('asso', 'Association'),
('eurl', 'EURL / Entreprise individuelle'),
('sarl', 'SARL'),
('sa', 'SA / SAS')
])

5
easy_my_coop_fr/views/subscription_template.xml

@ -2,10 +2,7 @@
<odoo>
<data>
<template id="subscription_i18n" inherit_id="easy_my_coop.becomecooperator" name="Removing fields">
<!-- <xpath expr="//label[@for='no_registre']/.." position="replace">
</xpath> -->
<xpath expr="//label[@for='iban']/.." position="replace">
</xpath>
<xpath expr="//label[@for='iban']/.." position="replace"/>
</template>
</data>
</odoo>

1
easy_my_coop_online_payment/controllers/main.py

@ -47,7 +47,6 @@ class SubscriptionWebsitePayment(website_payment):
'amount': float(amount),
'currency_id': int(currency_id),
'partner_id': partner_id,
'release_capital_request': capital_release_request.id,
}
if len(capital_release_request) > 0:

7
easy_my_coop_taxshelter_report/models/tax_shelter_declaration.py

@ -61,12 +61,13 @@ class TaxShelterDeclaration(models.Model):
"as non eligible")
def _excluded_from_declaration(self, entry):
# entry is a subscription.register object
if entry.date >= self.date_from and entry.date <= self.date_to:
declaration = self
declarations = self
else:
declaration = self.search([('date_from', '<=', entry.date),
declarations = self.search([('date_from', '<=', entry.date),
('date_to', '>=', entry.date)])
if entry.partner_id.id in declaration.excluded_cooperator.ids:
if entry.partner_id.id in declarations.mapped('excluded_cooperator').ids:
return True
return False

2
easy_my_coop_website_document/__openerp__.py

@ -15,7 +15,7 @@
'author': 'Rémy Taymans',
'license': 'AGPL-3',
'version': '9.0.1.0',
'website': "https://github.com/houssine78/vertical-cooperative",
'website': "www.coopiteasy.be",
'category': 'Website, Cooperative Management',

2
easy_my_coop_website_portal/__openerp__.py

@ -15,7 +15,7 @@
'author': 'Rémy Taymans',
'license': 'AGPL-3',
'version': '9.0.1.0',
'website': "https://github.com/houssine78/vertical-cooperative",
'website': "www.coopiteasy.be",
'category': 'Website, Cooperative Management',

2
easy_my_coop_website_taxshelter/__openerp__.py

@ -15,7 +15,7 @@
'author': 'Rémy Taymans',
'license': 'AGPL-3',
'version': '9.0.1.0',
'website': "https://github.com/houssine78/vertical-cooperative",
'website': "www.coopiteasy.be",
'category': 'Website, Cooperative Management',

2
website_portal_extend/__openerp__.py

@ -16,7 +16,7 @@
'author': 'Rémy Taymans',
'license': 'AGPL-3',
'version': '9.0.1.0',
'website': "https://github.com/houssine78/vertical-cooperative",
'website': "www.coopiteasy.be",
'category': 'Website',

Loading…
Cancel
Save