robin.keunen
5 years ago
7 changed files with 262 additions and 13 deletions
-
14easy_my_coop/demo/coop.xml
-
44easy_my_coop/demo/users.xml
-
2easy_my_coop/security/res_groups.xml
-
174easy_my_coop/tests/test_emc.py
-
2easy_my_coop_document/__openerp__.py
-
3easy_my_coop_loan/__manifest__.py
-
34easy_my_coop_loan/demo/coop.xml
@ -0,0 +1,44 @@ |
|||||
|
<?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_user_emc_demo" model="res.partner"> |
||||
|
<field name="name">User EMC</field> |
||||
|
<field name="customer" eval="False"/> |
||||
|
<field name="is_company" eval="False"/> |
||||
|
<field name="email">user.emc@coop.coop</field> |
||||
|
<field name="street">Rue de la colocation, 23</field> |
||||
|
<field name="city">Bruxelles</field> |
||||
|
<field name="zip">1030</field> |
||||
|
<field name="country_id" ref="base.be"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="res_users_user_emc_demo" model="res.users"> |
||||
|
<field name="partner_id" ref="res_partner_user_emc_demo"/> |
||||
|
<field name="login">user-emc</field> |
||||
|
<field name="password">demo</field> |
||||
|
<field name="groups_id" eval="[(4, ref('easy_my_coop.group_easy_my_coop_user'))]"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="res_partner_manager_emc_demo" model="res.partner"> |
||||
|
<field name="name">Manager EMC</field> |
||||
|
<field name="customer" eval="False"/> |
||||
|
<field name="is_company" eval="False"/> |
||||
|
<field name="email">manager.emc@coop.coop</field> |
||||
|
<field name="street">Rue de la colocation, 24</field> |
||||
|
<field name="city">Liège</field> |
||||
|
<field name="zip">4100</field> |
||||
|
<field name="country_id" ref="base.be"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="res_users_manager_emc_demo" model="res.users"> |
||||
|
<field name="partner_id" ref="res_partner_manager_emc_demo"/> |
||||
|
<field name="login">manager-emc</field> |
||||
|
<field name="password">demo</field> |
||||
|
<field name="groups_id" eval="[(4, ref('easy_my_coop.group_easy_my_coop_manager'))]"/> |
||||
|
</record> |
||||
|
|
||||
|
</odoo> |
@ -0,0 +1,174 @@ |
|||||
|
# Copyright 2019 Coop IT Easy SCRL fs |
||||
|
# Robin Keunen <robin@coopiteasy.be> |
||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
from odoo.fields import Date |
||||
|
from odoo.exceptions import AccessError |
||||
|
from .test_base import EMCBaseCase |
||||
|
|
||||
|
|
||||
|
class EMCCase(EMCBaseCase): |
||||
|
def setUp(self): |
||||
|
super(EMCCase, self).setUp() |
||||
|
|
||||
|
self.request = self.browse_ref( |
||||
|
"easy_my_coop.subscription_request_1_demo" |
||||
|
) |
||||
|
self.bank_journal_euro = self.env["account.journal"].create( |
||||
|
{"name": "Bank", "type": "bank", "code": "BNK67"} |
||||
|
) |
||||
|
self.payment_method_manual_in = self.env.ref( |
||||
|
"account.account_payment_method_manual_in" |
||||
|
) |
||||
|
|
||||
|
def test_put_on_waiting_list(self): |
||||
|
self.as_emc_user() |
||||
|
self.request.put_on_waiting_list() |
||||
|
self.assertEquals(self.request.state, "waiting") |
||||
|
|
||||
|
def test_validate_subscription_request(self): |
||||
|
self.as_emc_user() |
||||
|
self.request.validate_subscription_request() |
||||
|
|
||||
|
self.assertEquals(self.request.state, "done") |
||||
|
self.assertTrue(self.request.partner_id) |
||||
|
self.assertTrue(self.request.partner_id.coop_candidate) |
||||
|
self.assertFalse(self.request.partner_id.member) |
||||
|
self.assertEquals(self.request.type, "new") |
||||
|
self.assertTrue(len(self.request.capital_release_request) >= 1) |
||||
|
self.assertEquals(self.request.capital_release_request.state, "open") |
||||
|
self.assertTrue(self.request.capital_release_request.sent) |
||||
|
|
||||
|
def test_register_payment_for_capital_release(self): |
||||
|
self.as_emc_user() |
||||
|
self.request.validate_subscription_request() |
||||
|
invoice = self.request.capital_release_request |
||||
|
|
||||
|
ctx = {"active_model": "account.invoice", "active_ids": [invoice.id]} |
||||
|
register_payments = ( |
||||
|
self.env["account.register.payments"] |
||||
|
.with_context(ctx) |
||||
|
.create( |
||||
|
{ |
||||
|
"payment_date": Date.today(), |
||||
|
"journal_id": self.bank_journal_euro.id, |
||||
|
"payment_method_id": self.payment_method_manual_in.id, |
||||
|
} |
||||
|
) |
||||
|
) |
||||
|
register_payments.create_payments() |
||||
|
self.assertEquals(self.request.capital_release_request.state, "paid") |
||||
|
|
||||
|
partner = self.request.partner_id |
||||
|
self.assertFalse(partner.coop_candidate) |
||||
|
self.assertTrue(partner.member) |
||||
|
self.assertTrue(partner.share_ids) |
||||
|
self.assertEquals(self.request.partner_id.effective_date, Date.today()) |
||||
|
|
||||
|
share = partner.share_ids[0] |
||||
|
self.assertEquals(share.share_number, self.request.ordered_parts) |
||||
|
self.assertEquals( |
||||
|
share.share_product_id, self.request.share_product_id |
||||
|
) |
||||
|
self.assertEquals(share.effective_date, Date.today()) |
||||
|
|
||||
|
def test_user_rights(self): |
||||
|
|
||||
|
request_values = { |
||||
|
"name": "test create request", |
||||
|
"email": "test@demo.net", |
||||
|
"address": "schaerbeekstraat", |
||||
|
"zip_code": "1111", |
||||
|
"city": "Brussels", |
||||
|
"country_id": self.ref("base.be"), |
||||
|
"date": Date.today(), |
||||
|
"source": "manual", |
||||
|
"ordered_parts": 3, |
||||
|
"share_product_id": self.ref( |
||||
|
"easy_my_coop.product_template_share_type_2_demo" |
||||
|
).product_variant_id.id, |
||||
|
"lang": "en_US", |
||||
|
} |
||||
|
|
||||
|
# test ir model access for base user |
||||
|
self.as_user() |
||||
|
read_request = self.browse_ref( |
||||
|
"easy_my_coop.subscription_request_1_demo" |
||||
|
) |
||||
|
with self.assertRaises(AccessError): |
||||
|
read_request.name = "test write request" |
||||
|
with self.assertRaises(AccessError): |
||||
|
self.env["subscription.request"].create(request_values) |
||||
|
with self.assertRaises(AccessError): |
||||
|
read_request.unlink() |
||||
|
|
||||
|
share_line = self.browse_ref("easy_my_coop.share_line_1_demo") |
||||
|
with self.assertRaises(AccessError): |
||||
|
share_line.share_number = 3 |
||||
|
|
||||
|
# test ir model access for easy my coop user |
||||
|
self.as_emc_user() |
||||
|
read_request = self.browse_ref( |
||||
|
"easy_my_coop.subscription_request_1_demo" |
||||
|
) |
||||
|
read_request.name = "test write request" |
||||
|
create_request = self.env["subscription.request"].create( |
||||
|
request_values |
||||
|
) |
||||
|
with self.assertRaises(AccessError): |
||||
|
create_request.unlink() |
||||
|
|
||||
|
share_line = self.browse_ref("easy_my_coop.share_line_1_demo") |
||||
|
share_line.share_number = 3 |
||||
|
with self.assertRaises(AccessError): |
||||
|
share_line.unlink() |
||||
|
|
||||
|
share_type = self.browse_ref( |
||||
|
"easy_my_coop.product_template_share_type_1_demo" |
||||
|
) |
||||
|
share_type.list_price = 30 |
||||
|
with self.assertRaises(AccessError): |
||||
|
self.env["product.template"].create( |
||||
|
{ |
||||
|
"name": "Part C - Client", |
||||
|
"short_name": "Part C", |
||||
|
"is_share": True, |
||||
|
"default_share_product": True, |
||||
|
"force_min_qty": True, |
||||
|
"minimum_quantity": 2, |
||||
|
"by_individual": True, |
||||
|
"by_company": True, |
||||
|
"list_price": 50, |
||||
|
"display_on_website": True, |
||||
|
} |
||||
|
) |
||||
|
with self.assertRaises(AccessError): |
||||
|
share_type.unlink() |
||||
|
|
||||
|
# test ir model access for easy my coop manager |
||||
|
self.as_emc_manager() |
||||
|
read_request = self.browse_ref( |
||||
|
"easy_my_coop.subscription_request_1_demo" |
||||
|
) |
||||
|
read_request.name = "test write request" |
||||
|
create_request = self.env["subscription.request"].create( |
||||
|
request_values |
||||
|
) |
||||
|
create_request.unlink() |
||||
|
|
||||
|
share_type = self.env["product.template"].create( |
||||
|
{ |
||||
|
"name": "Part C - Client", |
||||
|
"short_name": "Part C", |
||||
|
"is_share": True, |
||||
|
"default_share_product": True, |
||||
|
"force_min_qty": True, |
||||
|
"minimum_quantity": 2, |
||||
|
"by_individual": True, |
||||
|
"by_company": True, |
||||
|
"list_price": 50, |
||||
|
"display_on_website": True, |
||||
|
} |
||||
|
) |
||||
|
share_type.list_price = 30 |
||||
|
share_type.unlink() |
@ -0,0 +1,34 @@ |
|||||
|
<?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="loan_issue_1_demo" model="loan.issue"> |
||||
|
<field name="name">test loan issue</field> |
||||
|
<field name="is_bond" eval="False"/> |
||||
|
<field name="is_loan" eval="True"/> |
||||
|
<field name="default_issue" eval="True"/> |
||||
|
<field name="subscription_start_date" eval="datetime.today()"/> |
||||
|
<field name="subscription_end_date" eval="datetime.today() + timedelta(days=60)"/> |
||||
|
<field name="term_date" eval="datetime.today() + timedelta(days=600)"/> |
||||
|
<field name="user_id" ref="easy_my_coop.res_users_manager_emc_demo"/> |
||||
|
<field name="rate">0.03</field> |
||||
|
<field name="face_value">100</field> |
||||
|
<field name="minimum_amount">4000</field> |
||||
|
<field name="maximum_amount">10000</field> |
||||
|
<field name="maximum_amount_per_sub">1000</field> |
||||
|
<field name="interest_payment">yearly</field> |
||||
|
<field name="by_company" eval="True"/> |
||||
|
<field name="by_individual" eval="True"/> |
||||
|
<field name="display_on_website" eval="True"/> |
||||
|
<field name="taxes_rate">0.08</field> |
||||
|
<field name="state">ongoing</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="loan_issue_line_1_demo" model="loan.issue.line"> |
||||
|
<field name="loan_issue_id" ref="loan_issue_1_demo"/> |
||||
|
<field name="quantity">3</field> |
||||
|
<field name="partner_id" ref="easy_my_coop.res_partner_cooperator_4_demo"/> |
||||
|
</record> |
||||
|
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue