Browse Source

Merge branch '12.0-emc-demo-data-and-tests' into 12.0

pull/23/head
robin.keunen 5 years ago
parent
commit
ebb143c9e1
  1. 39
      easy_my_coop/__manifest__.py
  2. 122
      easy_my_coop/demo/coop.xml
  3. 6
      easy_my_coop/models/account_invoice.py
  4. 6
      easy_my_coop/models/account_journal.py
  5. 6
      easy_my_coop/models/company.py
  6. 63
      easy_my_coop/models/coop.py
  7. 6
      easy_my_coop/models/operation_request.py
  8. 9
      easy_my_coop/models/partner.py
  9. 6
      easy_my_coop/models/product.py
  10. 6
      easy_my_coop/models/res_partner_bank.py
  11. 1
      easy_my_coop/tests/__init__.py
  12. 70
      easy_my_coop/tests/test_coop.py
  13. 17
      easy_my_coop_be/models/coop.py

39
easy_my_coop/__manifest__.py

@ -4,25 +4,25 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Easy My Coop",
"version": "12.0.2.0.2",
"depends": [
"base",
"web",
"sale",
"account",
"base_iban",
"product",
"partner_firstname",
"partner_contact_birthdate",
"partner_contact_address",
"email_template_config",
'name': 'Easy My Coop',
'version': '12.0.2.0.2',
'depends': [
'base',
'web',
'sale',
'account',
'base_iban',
'product',
'partner_firstname',
'partner_contact_birthdate',
'partner_contact_address',
'email_template_config',
],
"author": "Coop IT Easy SCRLfs",
"category": "Cooperative management",
"website": "https://www.coopiteasy.be",
"license": "AGPL-3",
"description": """
'author': 'Coop IT Easy SCRLfs',
'category': 'Cooperative management',
'website': 'https://www.coopiteasy.be',
'license': 'AGPL-3',
'description': """
This module allows to manage the cooperator subscription and all the
cooperative business processes.
""",
@ -51,6 +51,9 @@
'report/cooperator_register_G001.xml',
'data/mail_template_data.xml', # Must be loaded after reports
],
'demo': [
'demo/coop.xml',
],
'installable': True,
'application': True,
}

122
easy_my_coop/demo/coop.xml

@ -0,0 +1,122 @@
<?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="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="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="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="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="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"/>
</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"/>
</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_2_demo"/>
<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_number">2</field>
<field name="share_unit_price">50</field>
<field name="partner_id" ref="res_partner_cooperator_1_demo"/>
<field name="effective_date" eval="datetime.now() - timedelta(days=120)"/>
</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_number">4</field>
<field name="share_unit_price">50</field>
<field name="partner_id" ref="res_partner_cooperator_2_demo"/>
<field name="effective_date" eval="datetime.now() - timedelta(days=120)"/>
</record>
</odoo>

6
easy_my_coop/models/account_invoice.py

@ -1,3 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Coop IT Easy SCRL fs
# Houssine Bakkali <houssine@coopiteasy.be>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from datetime import datetime
from odoo import api, fields, models

6
easy_my_coop/models/account_journal.py

@ -1,3 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Coop IT Easy SCRL fs
# Houssine Bakkali <houssine@coopiteasy.be>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import fields, models

6
easy_my_coop/models/company.py

@ -1,3 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Coop IT Easy SCRL fs
# Houssine Bakkali <houssine@coopiteasy.be>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models

63
easy_my_coop/models/coop.py

@ -1,3 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Coop IT Easy SCRL fs
# Houssine Bakkali <houssine@coopiteasy.be>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from datetime import datetime
from odoo import api, fields, models, _
@ -404,7 +410,13 @@ class SubscriptionRequest(models.Model):
if self.company_id.property_cooperator_account:
account = self.company_id.property_cooperator_account
else:
account = account_obj.search([('code', '=', '416000')])[0]
accounts = account_obj.search([('code', '=', '416000')])
if accounts:
account = accounts[0]
else:
raise UserError(_(
'You must set a cooperator account on you company.'
))
return account
def get_invoice_vals(self, partner):
@ -445,7 +457,6 @@ class SubscriptionRequest(models.Model):
'city': self.city, 'email': self.company_email,
'out_inv_comm_type': 'bba',
'customer': self.share_product_id.customer,
'out_inv_comm_algorithm': 'random',
'country_id': self.country_id.id,
'lang': self.lang,
'data_policy_approved': self.data_policy_approved,
@ -459,8 +470,6 @@ class SubscriptionRequest(models.Model):
'zip': self.zip_code, 'email': self.email,
'gender': self.gender, 'cooperator': True,
'city': self.city, 'phone': self.phone,
'out_inv_comm_type': 'bba',
'out_inv_comm_algorithm': 'random',
'country_id': self.country_id.id, 'lang': self.lang,
'birthdate_date': self.birthdate,
'customer': self.share_product_id.customer,
@ -469,6 +478,29 @@ class SubscriptionRequest(models.Model):
}
return partner_vals
def get_representative_vals(self):
contact_vals = {
'name': self.name,
'firstname': self.firstname,
'lastname': self.lastname, 'customer': False,
'is_company': False, 'cooperator': True,
'street': self.address, 'gender': self.gender,
'zip': self.zip_code, 'city': self.city,
'phone': self.phone, 'email': self.email,
'country_id': self.country_id.id,
'out_inv_comm_type': 'bba',
'out_inv_comm_algorithm': 'random',
'lang': self.lang,
'birthdate_date': self.birthdate,
'parent_id': self.partner.id,
'representative': True,
'function': self.contact_person_function,
'type': 'representative',
'data_policy_approved': self.data_policy_approved,
'internal_rules_approved': self.internal_rules_approved
}
return contact_vals
def create_coop_partner(self):
partner_obj = self.env['res.partner']
@ -526,27 +558,8 @@ class SubscriptionRequest(models.Model):
if contact:
contact.type = 'representative'
if not contact:
contact_vals = {
'name': self.name,
'firstname': self.firstname,
'lastname': self.lastname, 'customer': False,
'is_company': False, 'cooperator': True,
'street': self.address, 'gender': self.gender,
'zip': self.zip_code, 'city': self.city,
'phone': self.phone, 'email': self.email,
'country_id': self.country_id.id,
'out_inv_comm_type': 'bba',
'out_inv_comm_algorithm': 'random',
'lang': self.lang,
'birthdate_date': self.birthdate,
'parent_id': partner.id,
'representative': True,
'function': self.contact_person_function,
'type': 'representative',
'data_policy_approved': self.data_policy_approved,
'internal_rules_approved': self.internal_rules_approved
}
contact = partner_obj.create(contact_vals)
contact_vals = self.get_representative_vals()
partner_obj.create(contact_vals)
else:
if len(contact) > 1:
raise UserError(_('There is two different persons with the'

6
easy_my_coop/models/operation_request.py

@ -1,4 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Coop IT Easy SCRL fs
# Houssine Bakkali <houssine@coopiteasy.be>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from datetime import datetime
from odoo import api, fields, models, _
@ -10,6 +15,7 @@ class operation_request(models.Model):
_description = "Operation request"
def get_date_now(self):
# fixme odoo 12 uses date types
return datetime.strftime(datetime.now(), '%Y-%m-%d')
@api.multi

9
easy_my_coop/models/partner.py

@ -1,3 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Coop IT Easy SCRL fs
# Houssine Bakkali <houssine@coopiteasy.be>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
@ -87,7 +93,7 @@ class ResPartner(models.Model):
cooperator = fields.Boolean(string='Cooperator',
help="Check this box if this contact is a"
" cooperator(effective or not).")
" cooperator (effective or not).")
member = fields.Boolean(string='Effective cooperator',
help="Check this box if this cooperator"
" is an effective member.")
@ -98,6 +104,7 @@ class ResPartner(models.Model):
old_member = fields.Boolean(string='Old cooperator',
help="Check this box if this cooperator is"
" no more an effective member.")
# todo use oca partner_contact_gender
gender = fields.Selection([('male', 'Male'),
('female', 'Female'),
('other', 'Other')],

6
easy_my_coop/models/product.py

@ -1,3 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Coop IT Easy SCRL fs
# Houssine Bakkali <houssine@coopiteasy.be>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models

6
easy_my_coop/models/res_partner_bank.py

@ -1,3 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Coop IT Easy SCRL fs
# Houssine Bakkali <houssine@coopiteasy.be>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models

1
easy_my_coop/tests/__init__.py

@ -0,0 +1 @@
from . import test_coop

70
easy_my_coop/tests/test_coop.py

@ -0,0 +1,70 @@
# -*- coding: utf-8 -*-
# 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).
import odoo.tests.common as common
from odoo.fields import Date
class TestCoop(common.TransactionCase):
def setUp(self):
super(TestCoop, 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.request.put_on_waiting_list()
self.assertEquals(self.request.state, "waiting")
def test_validate_subscription_request(self):
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.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())

17
easy_my_coop_be/models/coop.py

@ -8,3 +8,20 @@ class SubscriptionRequest(models.Model):
('asbl', 'ASBL'),
('sprl', 'SPRL'),
('sa', 'SA')])
def get_partner_company_vals(self):
vals = super(SubscriptionRequest).get_partner_company_vals()
vals['out_inv_comm_algorithm'] = 'random'
return vals
def get_partner_vals(self):
vals = super(SubscriptionRequest).get_partner_vals()
vals['out_inv_comm_type'] = 'bba'
vals['out_inv_comm_algorithm'] = 'random'
return vals
def get_representative_valst(self):
vals = super(SubscriptionRequest).get_representative_vals()
vals['out_inv_comm_type'] = 'bba'
vals['out_inv_comm_algorithm'] = 'random'
return vals
Loading…
Cancel
Save