Commit e885f059 authored by Luca Cristaldi's avatar Luca Cristaldi

style changes and some more

parent 79745bf3
......@@ -27,71 +27,67 @@ class Member(Workflow, ModelSQL, ModelView):
('draft', 'Draft'),
('running', 'Running'),
('stopped', 'Stopped'),
],
"State",
readonly=True)
code = fields.Char("Code",
select=True,
states={
'readonly': Eval('code_readonly', True),
'required': Eval('state') != 'draft'
},
depends=_depends + ['code_readonly'],
help="The internal identifier for the associate.")
],
"State",
readonly=True)
code = fields.Char("Code", select=True,
states={
'readonly': Eval('code_readonly', True),
'required': Eval('state') != 'draft'
},
depends=_depends + ['code_readonly'],
help="The internal identifier for the associate.")
code_readonly = fields.Function(fields.Boolean("Code Readonly"),
'get_code_readonly')
company = fields.Many2One('company.company',
"Company",
states={'readonly': Eval('state') != 'draft'},
depends=_depends,
required=True,
help="The association this member belongs to.")
party = fields.Many2One('party.party',
"Party",
states={'readonly': Eval('state') != 'draft'},
depends=_depends,
required=True,
help="The party that represents the member.")
company = fields.Many2One('company.company', "Company",
states={'readonly': Eval('state') != 'draft'},
depends=_depends,
required=True,
help="The association the member belongs to.")
party = fields.Many2One('party.party', "Party",
states={'readonly': Eval('state') != 'draft'},
depends=_depends,
required=True,
help="The party that represents the member.")
join_date = fields.Date("Join Date",
states={
'readonly':
(Eval('state') != 'draft') | Eval('join_date'),
'required':
Eval('state') != 'draft'
},
domain=[
If(
(Eval('join_date')) & (Eval('leave_date')),
('join_date', '<=', Eval('leave_date')),
(),
)
],
depends=_depends + ['leave_date'],
help="The date the member joined the association.")
states={
'readonly':
(Eval('state') != 'draft') | Eval('join_date'),
'required':
Eval('state') != 'draft'
},
domain=[
If(
(Eval('join_date')) & (Eval('leave_date')),
('join_date', '<=', Eval('leave_date')),
(),
)
],
depends=_depends + ['leave_date'],
help="The date the member joined the association.")
leave_date = fields.Date("Leave Date",
domain=[
If(
(Eval('join_date')) &
(Eval('leave_date')),
('leave_date', '>=', Eval('join_date')),
(),
)
],
depends=_depends + ['join_date'],
states={
'invisible': Eval('state') == 'draft',
'required': Eval('state') == 'stopped',
'readonly': Eval('state') != 'running'
},
help="The date the member left the association.")
memberships = fields.One2Many('association.membership',
'member',
"Memberships",
domain=[
('company', '=', Eval('company', -1))
],
depends=_depends + ['company'],
states=_states)
domain=[
If(
(Eval('join_date')) &
(Eval('leave_date')),
('leave_date', '>=', Eval('join_date')),
(),
)
],
depends=_depends + ['join_date'],
states={
'invisible': Eval('state') == 'draft',
'required': Eval('state') == 'stopped',
'readonly': Eval('state') != 'running'
},
help="The date the member left the association.")
memberships = fields.One2Many('association.membership', 'member',
"Memberships",
domain=[
('company', '=', Eval('company', -1))
],
depends=_depends + ['company'],
states=_states)
del _states, _depends
......@@ -102,6 +98,7 @@ class Member(Workflow, ModelSQL, ModelView):
cls._sql_constraints = [
('code_uniq', Unique(t, t.code), 'Member code must be unique.'),
]
cls._transitions |= {('draft', 'running'), ('running', 'draft'),
('running', 'stopped')}
......
This diff is collapsed.
......@@ -16,10 +16,16 @@ this repository contains the full copyright notices and license terms. -->
<field name="text">You cannot expel the member "%(member)s" because there are still some unpaid fees.</field>
</record>
<record model="ir.message" id="msg_period_fee_invalid">
<field name="text">The period "%(period)s" fee amount should have a value greather than zero.</field>
<field name="text">TThe fee amount for period "%(period)s" must be greater than or equal to zero.</field>
</record>
<record model="ir.message" id="msg_party_receivable_missing">
<field name="text">The party "%(party)s" doesn't have an account receivable defined.</field>
</record>
<record model="ir.message" id="msg_period_unique">
<field name="text">The periods for each member must be unique.</field>
</record>
<record model="ir.message" id="msg_overlapping_membership">
<field name="text">The membership "%(first)s" overlaps with the period "%(second)s".</field>
</record>
</data>
</tryton>
\ No newline at end of file
#!/usr/bin/env python3
# This file is part of Tryton. The COPYRIGHT file at the top level of
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import io
import os
import re
......@@ -9,9 +10,9 @@ from setuptools import setup, find_packages
def read(fname):
return io.open(os.path.join(os.path.dirname(__file__), fname),
'r',
encoding='utf-8').read()
return io.open(
os.path.join(os.path.dirname(__file__), fname),
'r', encoding='utf-8').read()
def get_require_version(name):
......@@ -19,8 +20,8 @@ def get_require_version(name):
require = '%s >= %s.%s.dev0, < %s.%s'
else:
require = '%s >= %s.%s, < %s.%s'
require %= (name, major_version, minor_version, major_version,
minor_version + 1)
require %= (name, major_version, minor_version,
major_version, minor_version + 1)
return require
......@@ -36,14 +37,15 @@ major_version = int(major_version)
minor_version = int(minor_version)
name = 'trytond_association'
download_url = 'http://downloads.tryton.org/%s.%s/' % (major_version,
minor_version)
download_url = 'http://downloads.tryton.org/%s.%s/' % (
major_version, minor_version)
if minor_version % 2:
version = '%s.%s.dev0' % (major_version, minor_version)
download_url = ('hg+http://hg.tryton.org/modules/%s#egg=%s-%s' %
(name[8:], name, version))
download_url = (
'hg+http://hg.tryton.org/modules/%s#egg=%s-%s' % (
name[8:], name, version))
requires = ['python-sql', 'python-stdnum']
requires = ['python-sql']
for dep in info.get('depends', []):
if not re.match(r'(ir|res)(\W|$)', dep):
requires.append(get_require_version('trytond_%s' % dep))
......@@ -54,8 +56,7 @@ dependency_links = []
if minor_version % 2:
dependency_links.append('https://trydevpi.tryton.org/')
setup(
name=name,
setup(name=name,
version=version,
description='Tryton module for association management',
long_description=read('README.rst'),
......
......@@ -85,7 +85,7 @@ Create honorary membership::
Add membership to member::
>>> _ = member.memberships.new(membership=honorary)
>>> _ = member.memberships.new(membership_type=honorary)
>>> member.save()
Enroll member::
......
......@@ -77,13 +77,13 @@ Create member::
>>> Member = Model.get('association.member')
>>> member = Member()
>>> member.party = party
>>> membership_line = member.memberships.new(membership=membership)
>>> membership_line = member.memberships.new(membership_type=membership)
>>> member.save()
Test membership inverse date::
>>> membership_line = member.memberships.new(
... membership=membership,
... membership_type=membership,
... start_date=start_date +timedelta,
... end_date=start_date)
>>> member.save() #doctest: +IGNORE_EXCEPTION_DETAIL
......@@ -95,7 +95,7 @@ Test membership inverse date::
Test membership unique::
>>> membership_line = member.memberships.new(membership=membership)
>>> membership_line = member.memberships.new(membership_type=membership)
>>> member.save()
Test memebrship fee::
......
......@@ -95,7 +95,7 @@ Create membership::
Add membership to member::
>>> memperships = [ membership1, membership2 ]
>>> _ = [ member.memberships.new(membership=m,start_date = start_date + datetime.timedelta(weeks=4),end_date = start_date + datetime.timedelta(weeks=50)) for m in memperships]
>>> _ = [ member.memberships.new(membership_type=m,start_date = start_date + datetime.timedelta(weeks=4),end_date = start_date + datetime.timedelta(weeks=50)) for m in memperships]
>>> member.join_date = start_date + datetime.timedelta(weeks=6)
>>> member.leave_date = start_date + datetime.timedelta(weeks=35)
>>> member.save()
......
......@@ -2,8 +2,8 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form>
<label name="membership"/>
<field name="membership"/>
<label name="membership_type"/>
<field name="membership_type"/>
<label name="start_date"/>
<field name="start_date"/>
<label name="end_date"/>
......
......@@ -2,8 +2,8 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form>
<label name="membership"/>
<field name="membership"/>
<label name="membership_type"/>
<field name="membership_type"/>
<label name="name"/>
<field name="name" />
<label name="start_date"/>
......
......@@ -2,7 +2,7 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tree editable="bottom">
<field name="membership" />
<field name="membership_type" />
<field name="start_date" />
<field name="end_date" />
</tree>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment