Browse Source

Merge pull request #36 from coopiteasy/12.0-handle-remarks-from-leloup

12.0 handle remarks from leloup
pull/44/head
Robin Keunen 5 years ago
committed by GitHub
parent
commit
85983f528c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      easy_my_coop/views/res_partner_view.xml
  2. 53
      easy_my_coop_loan/models/loan.py
  3. 20
      easy_my_coop_loan/views/loan_view.xml
  4. 4
      easy_my_coop_loan_website/controllers/main.py

4
easy_my_coop/views/res_partner_view.xml

@ -12,9 +12,9 @@
<field name="arch" type="xml">
<sheet position="before">
<header>
<button string="Create Subscription" name="%(action_view_create_subscription)d"
<button id="action_view_create_subscription" string="Create Subscription" name="%(action_view_create_subscription)d"
type="action" context="{'default_active_id': active_id}" groups="easy_my_coop.group_easy_my_coop_manager"/>
<button string="Update info" name="%(action_view_update_partner_info)d"
<button id="action_view_update_partner_info" string="Update info" name="%(action_view_update_partner_info)d"
type="action" context="{'default_active_id': active_id}" groups="easy_my_coop.group_easy_my_coop_manager"/>
</header>
</sheet>

53
easy_my_coop_loan/models/loan.py

@ -21,25 +21,29 @@ class LoanIssue(models.Model):
name = fields.Char(string="Name",
translate=True)
is_bond = fields.Boolean(string="Is a bond issue?")
is_loan = fields.Boolean(string="Is a subordinated loan issue?")
default_issue = fields.Boolean(string="Default issue")
subscription_start_date = fields.Date(string="Start date")
subscription_end_date = fields.Date(string="End date")
subscription_start_date = fields.Date(string="Start date subscription period")
subscription_end_date = fields.Date(string="End date subscription period")
user_id = fields.Many2one('res.users',
string="Responsible")
term_date = fields.Date(string="Term date")
loan_term = fields.Float(string="term of the loan")
loan_term = fields.Float(string="Duration of the loan")
rate = fields.Float(string="Interest rate")
face_value = fields.Monetary(string="Facial value",
currency_field='company_currency_id',
required=True)
minimum_amount = fields.Monetary(string="Minimum amount",
minimum_amount = fields.Monetary(string="Minimum amount of issue",
currency_field='company_currency_id')
maximum_amount = fields.Monetary(string="Maximum amount",
maximum_amount = fields.Monetary(string="Maximum amount of issue",
currency_field='company_currency_id')
maximum_amount_per_sub = fields.Monetary(
string="Maximum amount per subscription",
currency_field='company_currency_id')
min_amount_company = fields.Monetary(string="Minimum amount for a company",
currency_field='company_currency_id')
max_amount_company = fields.Monetary(string="Maximum amount for a company",
currency_field='company_currency_id')
min_amount_person = fields.Monetary(string="Minimum amount for a person",
currency_field='company_currency_id')
max_amount_person = fields.Monetary(string="Maximum amount for a person",
currency_field='company_currency_id')
subscribed_amount = fields.Monetary(string="Subscribed amount",
compute="_compute_subscribed_amount",
currency_field='company_currency_id')
@ -71,25 +75,24 @@ class LoanIssue(models.Model):
taxes_rate = fields.Float(string="Taxes on interest",
required=True)
@api.multi
def get_max_amount(self, partner):
lines = self.loan_issue_lines.filtered(
lambda r: r.partner_id == partner and r.state != 'cancelled')
already_subscribed = sum(line.amount for line in lines)
if partner.is_company:
max_amount = self.max_amount_company - already_subscribed
else:
max_amount = self.max_amount_person - already_subscribed
return max_amount
@api.multi
def toggle_display(self):
for loan_issue in self:
loan_issue.display_on_website = not loan_issue.display_on_website
@api.multi
def get_web_loan_issues(self, is_company):
loan_issues = self.search([
('is_loan', '=', True),
('display_on_website', '=', True),
('state', '=', 'ongoing')
])
if is_company is True:
return loan_issues.filtered('by_company')
else:
return loan_issues.filtered('by_individual')
@api.multi
def get_web_bond_issues(self, is_company):
def get_web_issues(self, is_company):
bond_issues = self.search([
('is_bond', '=', True),
('display_on_website', '=', True),
@ -100,12 +103,6 @@ class LoanIssue(models.Model):
else:
return bond_issues.filtered('by_company')
@api.multi
def get_web_issues(self, is_company):
issues = self.get_web_loan_issues(is_company)
issues = issues + self.get_web_bond_issues(is_company)
return issues
@api.multi
def action_confirm(self):
self.ensure_one()

20
easy_my_coop_loan/views/loan_view.xml

@ -55,21 +55,32 @@
<group>
<group>
<field name="name" />
<field name="is_loan" />
<field name="is_bond" />
<field name="default_issue" />
<field name="face_value" />
<field name="minimum_amount" />
<field name="maximum_amount" />
<field name="maximum_amount_per_sub" />
<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="by_company" />
<field name="company_currency_id" invisible="True" />
</group>
<group>
<field name="user_id" widget="selection" />
<field name="rate" />
<field name="taxes_rate" />
<label for="rate" string="Interest rate"/>
<div>
<field name="rate" class="oe_inline"/>
<span class="o_form_label oe_inline">%</span>
</div>
<label for="taxes_rate" string="Taxes on interest"/>
<div>
<field name="taxes_rate" class="oe_inline"/>
<span class="o_form_label oe_inline">%</span>
</div>
<field name="subscription_start_date" />
<field name="subscription_end_date" />
<field name="term_date" />
@ -88,6 +99,7 @@
<field name="face_value" />
<field name="amount" />
<field name="state" />
<field name="company_currency_id" invisible="True"/>
</tree>
</field>
</page>

4
easy_my_coop_loan_website/controllers/main.py

@ -12,11 +12,13 @@ class WebsiteLoanIssueSubscription(http.Controller):
methods=['POST'], website=True)
def get_loan_issue(self, loan_issue_id, **kw):
loan_issue_obj = request.env['loan.issue']
partner = request.env.user.partner_id
if loan_issue_id:
loan_issue = loan_issue_obj.sudo().browse(int(loan_issue_id))
max_amount = loan_issue.get_max_amount(partner)
return {
loan_issue.id: {
'max_amount': loan_issue.maximum_amount_per_sub,
'max_amount': max_amount,
'face_value': loan_issue.face_value,
}
}

Loading…
Cancel
Save