Compare commits
merge into: njeudy:12.0
njeudy:11.0
njeudy:12.0
njeudy:12.0-add-financial-risk
njeudy:12.0-backend_filter
njeudy:12.0-chg-monetary_fields
njeudy:12.0-easy_my_coop-module_category_cooperator_management
njeudy:12.0-emc-rest-connector
njeudy:12.0-emc_loan-o3-add-paid-amount
njeudy:12.0-emc_loan-o6-subscription_end_date
njeudy:12.0-fix-coop-validation
njeudy:12.0-flag-easymycoop-mail-template
njeudy:12.0-loan-improvements
njeudy:12.0-max-amount-per-share
njeudy:12.0-o4-net-interest-rate
njeudy:12.0-openupgrade
njeudy:12.0-small-changes
njeudy:12.0-touch-cooperator-type
njeudy:14.0-MIG-INITIAL
njeudy:9.0
njeudy:9.0-fix_tax_shelter_declaration_exclusion
njeudy:9.0-medor-hide_bank_and_birthdate
njeudy:9.0-tag
njeudy:9.0_remove_national_register_number
njeudy:myceliandre_usability
pull from: njeudy:9.0-fix_tax_shelter_declaration_exclusion
njeudy:11.0
njeudy:12.0
njeudy:12.0-add-financial-risk
njeudy:12.0-backend_filter
njeudy:12.0-chg-monetary_fields
njeudy:12.0-easy_my_coop-module_category_cooperator_management
njeudy:12.0-emc-rest-connector
njeudy:12.0-emc_loan-o3-add-paid-amount
njeudy:12.0-emc_loan-o6-subscription_end_date
njeudy:12.0-fix-coop-validation
njeudy:12.0-flag-easymycoop-mail-template
njeudy:12.0-loan-improvements
njeudy:12.0-max-amount-per-share
njeudy:12.0-o4-net-interest-rate
njeudy:12.0-openupgrade
njeudy:12.0-small-changes
njeudy:12.0-touch-cooperator-type
njeudy:14.0-MIG-INITIAL
njeudy:9.0
njeudy:9.0-fix_tax_shelter_declaration_exclusion
njeudy:9.0-medor-hide_bank_and_birthdate
njeudy:9.0-tag
njeudy:9.0_remove_national_register_number
njeudy:myceliandre_usability
129 Commits
12.0
...
9.0-fix_ta
54 changed files with 3805 additions and 2355 deletions
-
29easy_my_coop/__openerp__.py
-
128easy_my_coop/controllers/main.py
-
54easy_my_coop/data/mail_template_data.xml
-
173easy_my_coop/demo/coop.xml
-
2043easy_my_coop/i18n/fr.po
-
1781easy_my_coop/i18n/fr_BE.po
-
5easy_my_coop/i18n/nl_BE.po
-
15easy_my_coop/migrations/9.1.0.0.2/pre-migration.py
-
249easy_my_coop/models/account_invoice.py
-
68easy_my_coop/models/company.py
-
132easy_my_coop/models/coop.py
-
622easy_my_coop/models/operation_request.py
-
42easy_my_coop/models/partner.py
-
15easy_my_coop/report/cooperator_certificat_G001.xml
-
6easy_my_coop/view/account_invoice_view.xml
-
3easy_my_coop/view/cooperator_register_view.xml
-
6easy_my_coop/view/email_template_view.xml
-
33easy_my_coop/view/menu.xml
-
8easy_my_coop/view/menu_item_view.xml
-
10easy_my_coop/view/operation_request_view.xml
-
15easy_my_coop/view/product_view.xml
-
11easy_my_coop/view/res_company_view.xml
-
24easy_my_coop/view/res_partner_view.xml
-
17easy_my_coop/view/subscription_request_view.xml
-
327easy_my_coop/view/subscription_template.xml
-
41easy_my_coop/wizard/cooperative_history_wizard.xml
-
41easy_my_coop/wizard/create_subscription_from_partner.py
-
2easy_my_coop/wizard/create_subscription_from_partner.xml
-
58easy_my_coop/wizard/update_partner_info.py
-
7easy_my_coop/wizard/update_partner_info.xml
-
1easy_my_coop/wizard/update_share_line.py
-
1easy_my_coop_be/__init__.py
-
2easy_my_coop_be/models/__init__.py
-
11easy_my_coop_be/models/coop.py
-
11easy_my_coop_be/models/partner.py
-
1easy_my_coop_ch/__openerp__.py
-
3easy_my_coop_ch/models/__init__.py
-
27easy_my_coop_ch/models/coop.py
-
17easy_my_coop_ch/models/partner.py
-
13easy_my_coop_ch/views/subscription_request_view.xml
-
18easy_my_coop_ch/views/subscription_template.xml
-
3easy_my_coop_eater/__openerp__.py
-
28easy_my_coop_eater/demo/eaters.xml
-
14easy_my_coop_export_xlsx/wizard/export_global_wizard.py
-
1easy_my_coop_fr/models/__init__.py
-
10easy_my_coop_fr/models/coop.py
-
13easy_my_coop_fr/models/partner.py
-
5easy_my_coop_fr/views/subscription_template.xml
-
1easy_my_coop_online_payment/controllers/main.py
-
7easy_my_coop_taxshelter_report/models/tax_shelter_declaration.py
-
2easy_my_coop_website_document/__openerp__.py
-
2easy_my_coop_website_portal/__openerp__.py
-
2easy_my_coop_website_taxshelter/__openerp__.py
-
2website_portal_extend/__openerp__.py
@ -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
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
File diff suppressed because it is too large
View File
@ -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") |
@ -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 |
@ -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) |
@ -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> |
@ -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> |
@ -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> |
@ -0,0 +1 @@ |
|||
from . import models |
@ -0,0 +1,2 @@ |
|||
from . import coop |
|||
from . import partner |
@ -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')]) |
@ -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 +1,2 @@ |
|||
from . import coop |
|||
from . import coop |
|||
from . import partner |
@ -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') |
|||
]) |
@ -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> |
@ -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> |
@ -1 +1,2 @@ |
|||
from . import coop |
|||
from . import partner |
@ -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') |
|||
]) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue