Browse Source

[ADD] demo data

pull/33/head
robin.keunen 5 years ago
parent
commit
633428c9f5
  1. 14
      easy_my_coop/demo/coop.xml
  2. 44
      easy_my_coop/demo/users.xml
  3. 2
      easy_my_coop/security/res_groups.xml
  4. 174
      easy_my_coop/tests/test_emc.py
  5. 4
      easy_my_coop_document/__openerp__.py
  6. 3
      easy_my_coop_loan/__manifest__.py
  7. 34
      easy_my_coop_loan/demo/coop.xml

14
easy_my_coop/demo/coop.xml

@ -93,10 +93,6 @@
<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"/>
</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>
@ -110,10 +106,6 @@
<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"/>
</record>
<record id="subscription_request_1_demo" model="subscription.request">
<field name="name">Manuel Dublues</field>
<field name="email">manuel@demo.net</field>
@ -124,12 +116,12 @@
<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_2_demo"/>
<field name="share_product_id" model="product.template" eval="obj(ref('product_template_share_type_2_demo')).product_variant_id.id"/>
<field name="lang">en_US</field>
</record>
<record id="share_line_1_demo" model="share.line">
<field name="share_product_id" ref="product_product_share_type_1_demo"/>
<field name="share_product_id" model="product.template" eval="obj(ref('product_template_share_type_1_demo')).product_variant_id.id"/>
<field name="share_number">2</field>
<field name="share_unit_price">50</field>
<field name="partner_id" ref="res_partner_cooperator_1_demo"/>
@ -137,7 +129,7 @@
</record>
<record id="share_line_2_demo" model="share.line">
<field name="share_product_id" ref="product_product_share_type_1_demo"/>
<field name="share_product_id" model="product.template" eval="obj(ref('product_template_share_type_1_demo')).product_variant_id.id"/>
<field name="share_number">4</field>
<field name="share_unit_price">50</field>
<field name="partner_id" ref="res_partner_cooperator_2_demo"/>

44
easy_my_coop/demo/users.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>

2
easy_my_coop/security/res_groups.xml

@ -3,7 +3,7 @@
<record id="group_easy_my_coop_user" model="res.groups">
<field name="name">User</field>
<field name="category_id" ref="module_category_cooperator_management"/>
<field name="implied_ids" eval="[(6, 0, [ref('base.group_user'), ref('account.group_account_invoice'), ref('sales_team.group_sale_salesman')])]"/>
<field name="implied_ids" eval="[(6, 0, [ref('base.group_user'), ref('account.group_account_invoice')])]"/>
</record>
<record id="group_easy_my_coop_manager" model="res.groups">

174
easy_my_coop/tests/test_emc.py

@ -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()

4
easy_my_coop_document/__openerp__.py

@ -4,7 +4,9 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
# migrate in v12 and isolate from emc
# migrate in v12 and isolate from emc
# add manager group or use relevant existing group
# add ir.model.access rules for that user
'name': 'Easy My Coop Document',
'summary': """

3
easy_my_coop_loan/__manifest__.py

@ -23,5 +23,8 @@
'views/menus.xml',
'data/mail_template_data.xml',
],
"demo": [
"demo/coop.xml",
],
'installable': True,
}

34
easy_my_coop_loan/demo/coop.xml

@ -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>
Loading…
Cancel
Save