Commit 495ffaf8 authored by Luca Cristaldi's avatar Luca Cristaldi

Reformat as requested from dave

parent 6596a0f2
......@@ -12,26 +12,24 @@ __all__ = ['register']
def register():
Pool.register(account.Move,
configuration.Configuration,
configuration.MemberSequence,
ir.Cron,
member.Member,
member.PrintMembersBookStart,
membership.Membership,
membership.Period,
membership.Fee,
membership.Line,
membership.GenerateFeeStart,
module='association',
type_='model')
Pool.register(member.MembersBookWizard,
membership.PostFee,
membership.GenerateFee,
module='association',
type_='wizard')
Pool.register(member.MembersBookReport,
module='association',
type_='report')
Pool.register(
account.Move,
configuration.Configuration,
configuration.MemberSequence,
ir.Cron,
member.Member,
member.PrintMembersBookStart,
membership.Membership,
membership.Period,
membership.Fee,
membership.Line,
membership.GenerateFeeStart,
module='association', type_='model')
Pool.register(
member.MembersBookWizard,
membership.PostFee,
membership.GenerateFee,
module='association', type_='wizard')
Pool.register(
member.MembersBookReport,
module='association', type_='report')
......@@ -14,25 +14,23 @@ class Configuration(ModelSingleton, ModelSQL, ModelView,
"""Association Configuration"""
__name__ = 'association.configuration'
member_sequence = fields.MultiValue(
fields.Many2One('ir.sequence',
"Member Sequence",
required=True,
domain=[
('company', 'in',
[Eval('context', {}).get('company', -1), None]),
('code', '=', 'association.member'),
]))
fields.Many2One('ir.sequence', "Member Sequence", required=True,
domain=[
('company', 'in',
[Eval('context', {}).get('company', -1), None]),
('code', '=', 'association.member'),
],
help="Used to generate the number given to association members."))
class MemberSequence(ModelSQL, CompanyValueMixin):
"""Member Configuration Sequence"""
__name__ = 'association.configuration.member_sequence'
member_sequence = fields.Many2One('ir.sequence',
"Member Sequence",
required=True,
domain=[
('company', 'in',
[Eval('company', -1), None]),
('code', '=', 'association.member'),
],
depends=['company'])
member_sequence = fields.Many2One('ir.sequence', "Member Sequence",
required=True,
domain=[
('company', 'in',
[Eval('company', -1), None]),
('code', '=', 'association.member'),
],
depends=['company'])
<?xml version="1.0"?>
<?xml version="1.0" ?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="ir.ui.view" id="association_configuration_view_form">
......@@ -10,25 +12,19 @@
<field name="name">Member Configuration</field>
<field name="res_model">association.configuration</field>
</record>
<record model="ir.action.act_window.view"
id="act_association_configuration_view1">
<record model="ir.action.act_window.view" id="act_association_configuration_view1">
<field name="sequence" eval="1"/>
<field name="view" ref="association_configuration_view_form"/>
<field name="act_window" ref="act_association_configuration_form"/>
</record>
<menuitem parent="menu_configuration"
action="act_association_configuration_form"
id="menu_association_configuration"
sequence="0" icon="tryton-list"/>
<record model="ir.ui.menu-res.group"
id="menu_association_configuration_group_member_admin">
<menuitem parent="menu_configuration" action="act_association_configuration_form" id="menu_association_configuration" sequence="0" icon="tryton-list"/>
<record model="ir.ui.menu-res.group" id="menu_association_configuration_group_member_admin">
<field name="menu" ref="menu_association_configuration"/>
<field name="group" ref="group_association_admin"/>
</record>
</data>
<data noupdate="1">
<record model="association.configuration.member_sequence"
id="configuration_member_sequence">
<record model="association.configuration.member_sequence" id="configuration_member_sequence">
<field name="member_sequence" ref="sequence_member"/>
</record>
</data>
......
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"/></svg>
\ No newline at end of file
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.model import Workflow, ModelView, ModelSQL, fields, Unique
from trytond.pyson import Eval, If
from trytond.transaction import Transaction
......@@ -8,6 +7,7 @@ from trytond.pool import Pool
from trytond.i18n import gettext
from trytond.wizard import Wizard, StateView, Button, StateReport
from trytond.report import Report
from .exceptions import MemberUnpaidFeeError
__all__ = [
......@@ -32,62 +32,48 @@ class Member(Workflow, ModelSQL, ModelView):
_rec_name = 'party_name'
party_name = fields.Function(fields.Char("Party Name"),
'on_change_with_party_name',
searcher='search_party_member')
'on_change_with_party_name',
searcher='search_party_member')
state = fields.Selection(STATES, 'State', readonly=True)
code = fields.Char('Code',
required=True,
select=True,
states={'readonly': Eval('code_readonly', True)},
depends=['code_readonly'],
help="The unique identifier of the associate.")
code = fields.Char('Code', required=True, select=True,
states={'readonly': Eval('code_readonly', True)},
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=_STATE,
depends=_DEPENDS,
required=True,
help="The association this member belongs to")
party = fields.Many2One('party.party',
'Party',
states=_STATE,
depends=_DEPENDS,
required=True,
help="The party representing this member")
'get_code_readonly')
company = fields.Many2One('company.company', 'Company', states=_STATE,
depends=_DEPENDS,
required=True,
help="The association this member belongs to.")
party = fields.Many2One('party.party', 'Party', states=_STATE,
depends=_DEPENDS,
required=True,
help="The party that represents the member.")
join_date = fields.Date('Join Date',
domain=[
If(
(Eval('join_date')) & (Eval('leave_date')),
('join_date', '<=', Eval('leave_date')),
(),
)
],
depends=['leave_date', 'state'],
states={'readonly': Eval('state') != 'draft'},
help="When the member joins the association.")
states={'readonly': Eval('state') != 'draft'},
domain=[
If(
(Eval('join_date')) & (Eval('leave_date')),
('join_date', '<=', Eval('leave_date')),
(),
)],
depends=['leave_date', 'state'],
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=['join_date', 'state'],
states={
'readonly':
Eval('state') != 'running',
'invisible':
~Eval('state').in_(['running', 'stopped'])
},
help="When the member leaves the association.")
memberships = fields.One2Many(
'association.membership.line',
'member',
domain=[
If(
(Eval('join_date')) & (Eval('leave_date')),
('leave_date', '>=', Eval('join_date')),
(),
)],
depends=['join_date', 'state'],
states={
'readonly': Eval('state') != 'running',
'invisible': ~Eval('state').in_(['running', 'stopped'])
},
help="The date the member left the association.")
memberships = fields.One2Many('association.membership.line', 'member',
"Memberships",
depends=['state'],
states={'readonly': Eval('state') != 'draft'})
......
<?xml version="1.0" ?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data depends="">
<!-- Icons -->
<record model="ir.ui.icon" id="association_icon">
<field name="name">tryton-association</field>
<field name="path">icons/tryton-association.svg</field>
</record>
<!-- Groups -->
<record model="res.group" id="group_association">
<field name="name">Association</field>
......@@ -24,7 +31,7 @@
<field name="user" ref="res.user_admin" />
<field name="group" ref="group_member_approval" />
</record>
<menuitem name="Association" sequence="0" id="menu_association" icon="tryton-party" />
<menuitem name="Association" sequence="0" id="menu_association" icon="tryton-association" />
<menuitem name="Configuration" parent="menu_association" id="menu_configuration" sequence="0" icon="tryton-settings" />
<record model="ir.ui.menu-res.group" id="menu_configuration_group_association_admin">
<field name="menu" ref="menu_configuration" />
......
This diff is collapsed.
<?xml version="1.0" ?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data depends="">
<!-- Membership -->
......
<?xml version="1.0" ?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data group="1">
<record model="ir.message" id="msg_date_non_in_period">
......
......@@ -57,6 +57,13 @@ Create member::
>>> member.party = party
>>> member.save()
Get a revenue journal::
>>> Journal = Model.get('account.journal')
>>> journal_revenue, = Journal.find([
... ('code', '=', 'REV'),
... ])
Create membership::
>>> Membership = Model.get('association.membership')
......@@ -65,6 +72,7 @@ Create membership::
>>> membership.party = party
>>> membership.name = "testo"
>>> membership.account_revenue = revenue
>>> membership.journal = journal_revenue
>>> start_date = datetime.date(2018,1,1)
>>> timedelta = datetime.timedelta(weeks=4)
>>> fiscalMonth = 13
......
......@@ -27,7 +27,6 @@ Create company::
>>> _ = create_company()
>>> company = get_company()
Create fiscal year::
>>> fiscalyear = create_fiscalyear(company)
......@@ -60,6 +59,13 @@ Create member::
>>> member.party = party
>>> member.save()
Get a revenue journal::
>>> Journal = Model.get('account.journal')
>>> journal_revenue, = Journal.find([
... ('code', '=', 'REV'),
... ])
Create membership::
>>> start_date = datetime.date(2018,1,1)
......@@ -71,6 +77,7 @@ Create membership::
>>> membership1.party = party
>>> membership1.name = "membership1"
>>> membership1.account_revenue = revenue
>>> membership1.journal = journal_revenue
>>> datedeltas = [(start_date + timedelta*(n-1) + datetime.timedelta(days=1),start_date + timedelta*n,f"{membership1.name} - {n}") for n in range(1,fiscalMonth+1)]
>>> periods1 = [ membership1.periods.new(start_date=period[0],end_date=period[1], name=period[2], amount=Decimal(42)) for period in datedeltas ]
>>> membership1.save()
......@@ -80,6 +87,7 @@ Create membership::
>>> membership2.party = party
>>> membership2.name = "membership2:Electric boogaloo"
>>> membership2.account_revenue = revenue
>>> membership2.journal = journal_revenue
>>> datedeltas = [(start_date + timedelta*(n-1) + datetime.timedelta(days=1),start_date + timedelta*n,f"{membership2.name} - {n}") for n in range(1,fiscalMonth+1)]
>>> periods2 = [ membership2.periods.new(start_date=period[0],end_date=period[1], name=period[2], amount=Decimal(42)) for period in datedeltas ]
>>> membership2.save()
......
<?xml version="1.0"?>
<?xml version="1.0" ?>
<!-- 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="member_sequence"/>
<field name="member_sequence"/>
......
<?xml version="1.0" ?>
<!-- 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 col="2">
<image name="tryton-info" xexpand="0" xfill="0"/>
<group col="2" xexpand="1" id="association_company">
......
<?xml version="1.0" ?>
<!-- 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 col="6">
<label name="code" />
<field name="code" />
......@@ -14,13 +16,10 @@
<page string="Memberships" id="membership_lines">
<field name="memberships" colspan="6" view_ids="association.membership_line_view_tree_editable" />
</page>
<page string="other" id="other">
<page string="Other" id="other">
<label name="company" />
<field name="company" />
</page>
<!-- <page string="Fees" id="fees_lines">
<field name="fees" colspan="6" view_ids="association.membership_fee_view_tree" />
</page> -->
</notebook>
<newline />
<label name="state" />
......
<?xml version="1.0"?>
<?xml version="1.0" ?>
<!-- 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>
<field name="code"/>
<field name="party"/>
......
<?xml version="1.0"?>
<?xml version="1.0" ?>
<!-- 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="member" />
<field name="member" />
......
<?xml version="1.0"?>
<?xml version="1.0" ?>
<!-- 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>
<field name="member" />
<field name="period" />
......
<?xml version="1.0" ?>
<!-- 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 col="2">
<image name="tryton-info" xexpand="0" xfill="0"/>
<group col="2" xexpand="1" id="create_date">
......
<?xml version="1.0" ?>
<!-- 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 col="4">
<label name="name" />
<field name="name" />
......
<?xml version="1.0"?>
<?xml version="1.0" ?>
<!-- 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"/>
......
<?xml version="1.0"?>
<?xml version="1.0" ?>
<!-- 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="start_date" />
......
<?xml version="1.0"?>
<?xml version="1.0" ?>
<!-- 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"/>
......
<?xml version="1.0"?>
<?xml version="1.0" ?>
<!-- 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="name" />
<field name="start_date"/>
......
<?xml version="1.0"?>
<?xml version="1.0" ?>
<!-- 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="name" />
<field name="start_date" />
......
<?xml version="1.0"?>
<?xml version="1.0" ?>
<!-- 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>
<field name="name"></field>
</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