Browse Source

Merge branch '12.0-small-changes' into 12.0

pull/46/head
robin.keunen 5 years ago
parent
commit
7485b23566
  1. 12
      easy_my_coop/models/coop.py
  2. 19
      easy_my_coop/models/mail_template.py
  3. 2
      easy_my_coop/views/subscription_request_view.xml
  4. 226
      easy_my_coop_loan/data/mail_template_data.xml
  5. 2
      easy_my_coop_loan/models/loan.py
  6. 9
      easy_my_coop_loan/views/loan_view.xml

12
easy_my_coop/models/coop.py

@ -58,7 +58,6 @@ class SubscriptionRequest(models.Model):
@api.model
def create(self, vals):
partner_obj = self.env['res.partner']
mail_template_notif = self.get_mail_template_notif(False)
if not vals.get('partner_id'):
cooperator = False
@ -81,13 +80,13 @@ class SubscriptionRequest(models.Model):
cooperator.write({'cooperator': True})
subscr_request = super(SubscriptionRequest, self).create(vals)
mail_template_notif = subscr_request.get_mail_template_notif(False)
mail_template_notif.send_mail(subscr_request.id)
return subscr_request
@api.model
def create_comp_sub_req(self, vals):
confirmation_mail_template = self.get_mail_template_notif(True)
vals["name"] = vals['company_name']
if not vals.get('partner_id'):
cooperator = self.env['res.partner'].get_cooperator_from_crn(vals.get('company_register_number'))
@ -97,6 +96,7 @@ class SubscriptionRequest(models.Model):
vals['already_cooperator'] = True
subscr_request = super(SubscriptionRequest, self).create(vals)
confirmation_mail_template = subscr_request.get_mail_template_notif(True)
confirmation_mail_template.send_mail(subscr_request.id)
return subscr_request
@ -502,7 +502,7 @@ class SubscriptionRequest(models.Model):
'out_inv_comm_algorithm': 'random',
'lang': self.lang,
'birthdate_date': self.birthdate,
'parent_id': self.partner.id,
'parent_id': self.partner_id.id,
'representative': True,
'function': self.contact_person_function,
'type': 'representative',
@ -553,11 +553,9 @@ class SubscriptionRequest(models.Model):
if domain:
partner = partner_obj.search(domain)
if not partner.cooperator:
partner.cooperator = True
if not partner:
partner = self.create_coop_partner()
self.partner_id = partner
else:
partner = partner[0]
@ -588,7 +586,7 @@ class SubscriptionRequest(models.Model):
'representative': True})
invoice = self.create_invoice(partner)
self.write({'partner_id': partner.id, 'state': 'done'})
self.write({'state': 'done'})
self.set_membership()
return invoice

19
easy_my_coop/models/mail_template.py

@ -1,12 +1,7 @@
from odoo import models, fields
class MailTemplate(models.Model):
_inherit = "mail.template"
# def init(self):
# for template_id in EMAIL_TEMPLATE_IDS:
# mail_template = self.env.ref(template_id)
# mail_template.easy_my_coop = True
easy_my_coop = fields.Boolean(string="Easy my coop mail template")
from odoo import models, fields
class MailTemplate(models.Model):
_inherit = "mail.template"
easy_my_coop = fields.Boolean(string="Easy my coop mail template")

2
easy_my_coop/views/subscription_request_view.xml

@ -34,7 +34,7 @@
<header>
<button string="Validate" type="object" name="validate_subscription_request" attrs="{'invisible':['|',('state','not in',['draft','waiting']),('validated','=',False)]}"/>
<button string="Waiting list" type="object" name="put_on_waiting_list" states="draft"/>
<button string="Cancel" type="object" name="cancel_subscription_request" states="draft,done,block" groups="easy_my_coop.group_easy_my_coop_user"/>
<button string="Cancel" type="object" name="cancel_subscription_request" states="draft,waiting,done,block" groups="easy_my_coop.group_easy_my_coop_user"/>
<field name="state" widget="statusbar" statusbar_visible="draft,cancelled,done,failed"/>
</header>
<sheet>

226
easy_my_coop_loan/data/mail_template_data.xml

@ -1,113 +1,113 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Mail template are declared in a NOUPDATE block
so users can freely customize/delete them -->
<data noupdate="1">
<record id="loan_subscription_confirmation" model="mail.template">
<field name="name">Loan Subscription Confirmation Email</field>
<field name="email_from">${(object.company_id.coop_email_contact or object.loan_issue_id.user_id.email)|safe}</field>
<field name="subject">${object.company_id.name} Loan subscription confirmation (Ref ${object.loan_issue_id.name or 'n/a'})</field>
<field name="email_to">${object.partner_id.email}</field>
<field name="reply_to">${(object.company_id.coop_email_contact or object.loan_issue_id.user_id.email)|safe}</field>
<field name="model_id" ref="easy_my_coop_loan.model_loan_issue_line"/>
<field name="auto_delete" eval="True"/>
<field name="lang">${object.partner_id.lang}</field>
<field name="easy_my_coop" eval="True"/>
<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.partner_id.name},</p>
<p>Your request will be soon processed by our team. If all the provided info are correct you will soon receive the payment information in another email</p>
<br/>
<p>If you have any question, do not hesitate to contact us.</p>
<br/>
<p>Sustainably your,</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>
</div>
]]></field>
</record>
<!--Request the payment of the subscribed loan issue -->
<record id="loan_issue_payment_request" model="mail.template">
<field name="name">Loan Issue Payment Request - Send by Email</field>
<field name="email_from">${(object.company_id.coop_email_contact or object.loan_issue_id.user_id.email)|safe}</field>
<field name="subject">${object.company_id.name} Payment request (Ref ${object.loan_issue_id.name or 'n/a'})</field>
<field name="partner_to">${object.partner_id.id}</field>
<field name="reply_to">${(object.company_id.coop_email_contact or object.loan_issue_id.user_id.email)|safe}</field>
<field name="model_id" ref="easy_my_coop_loan.model_loan_issue_line"/>
<field name="auto_delete" eval="True"/>
<field name="lang">${object.partner_id.lang}</field>
<field name="easy_my_coop" eval="True"/>
<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.partner_id.name},</p>
<p>Find here after the necessary information for the payment. We kindly remind you that your subscription will be effective only once we received the payment.</p>
<p>Amount: ${object.amount} ${object.loan_issue_id.company_currency_id.symbol}</p>
<p>Account number: ${object.company_id.bank_ids[0].sanitized_acc_number}</p>
<p>Communication: ${object.loan_issue_id.name} + ${object.partner_id.name}</p>
<p>Sustainably your,</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>
</div>
]]></field>
</record>
</data>
</odoo>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Mail template are declared in a NOUPDATE block
so users can freely customize/delete them -->
<data noupdate="1">
<record id="loan_subscription_confirmation" model="mail.template">
<field name="name">Loan Subscription Confirmation Email</field>
<field name="email_from">${(object.company_id.coop_email_contact or object.loan_issue_id.user_id.email)|safe}</field>
<field name="subject">${object.company_id.name} Loan subscription confirmation (Ref ${object.loan_issue_id.name or 'n/a'})</field>
<field name="email_to">${object.partner_id.email}</field>
<field name="reply_to">${(object.company_id.coop_email_contact or object.loan_issue_id.user_id.email)|safe}</field>
<field name="model_id" ref="easy_my_coop_loan.model_loan_issue_line"/>
<field name="auto_delete" eval="True"/>
<field name="lang">${object.partner_id.lang}</field>
<field name="easy_my_coop" eval="True"/>
<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.partner_id.name},</p>
<p>Your request will be soon processed by our team. If all the provided info are correct you will soon receive the payment information in another email</p>
<br/>
<p>If you have any question, do not hesitate to contact us.</p>
<br/>
<p>Sustainably your,</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>
</div>
]]></field>
</record>
<!--Request the payment of the subscribed loan issue -->
<record id="loan_issue_payment_request" model="mail.template">
<field name="name">Loan Issue Payment Request - Send by Email</field>
<field name="email_from">${(object.company_id.coop_email_contact or object.loan_issue_id.user_id.email)|safe}</field>
<field name="subject">${object.company_id.name} Payment request (Ref ${object.loan_issue_id.name or 'n/a'})</field>
<field name="partner_to">${object.partner_id.id}</field>
<field name="reply_to">${(object.company_id.coop_email_contact or object.loan_issue_id.user_id.email)|safe}</field>
<field name="model_id" ref="easy_my_coop_loan.model_loan_issue_line"/>
<field name="auto_delete" eval="True"/>
<field name="lang">${object.partner_id.lang}</field>
<field name="easy_my_coop" eval="True"/>
<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.partner_id.name},</p>
<p>Find here after the necessary information for the payment. We kindly remind you that your subscription will be effective only once we received the payment.</p>
<p>Amount: ${object.amount} ${object.loan_issue_id.company_currency_id.symbol}</p>
<p>Account number: ${object.company_id.bank_ids[0].sanitized_acc_number}</p>
<p>Communication: ${object.loan_issue_id.name} + ${object.partner_id.name}</p>
<p>Sustainably your,</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>
</div>
]]></field>
</record>
</data>
</odoo>

2
easy_my_coop_loan/models/loan.py

@ -20,7 +20,6 @@ class LoanIssue(models.Model):
name = fields.Char(string="Name",
translate=True)
is_bond = fields.Boolean(string="Is a bond issue?")
default_issue = fields.Boolean(string="Default issue")
subscription_start_date = fields.Date(string="Start date subscription period")
subscription_end_date = fields.Date(string="End date subscription period")
@ -94,7 +93,6 @@ class LoanIssue(models.Model):
@api.multi
def get_web_issues(self, is_company):
bond_issues = self.search([
('is_bond', '=', True),
('display_on_website', '=', True),
('state', '=', 'ongoing')
])

9
easy_my_coop_loan/views/loan_view.xml

@ -56,18 +56,17 @@
<group>
<group>
<field name="name" />
<field name="is_bond" />
<field name="default_issue" />
<field name="face_value" />
<field name="minimum_amount" />
<field name="maximum_amount" />
<field name="subscribed_amount" />
<field name="min_amount_person" />
<field name="max_amount_person" />
<field name="min_amount_company" />
<field name="max_amount_company" />
<field name="by_individual" />
<field name="min_amount_person" attrs="{'invisible':[('by_individual','=',False)]}" />
<field name="max_amount_person" attrs="{'invisible':[('by_individual','=',False)]}" />
<field name="by_company" />
<field name="min_amount_company" attrs="{'invisible':[('by_company','=',False)]}" />
<field name="max_amount_company" attrs="{'invisible':[('by_company','=',False)]}" />
<field name="company_currency_id" invisible="True" />
</group>
<group>

Loading…
Cancel
Save