Commit 2eab88d1 authored by Luca Cristaldi's avatar Luca Cristaldi

Make pep8 happy

parent 1b13c73d
......@@ -9,26 +9,24 @@ __all__ = ['register']
def register():
Pool.register(
Member,
Configuration,
MemberSequence,
Membership,
Period,
Fee,
Line,
Move,
GenerateFeeStart,
Cron,
PrintMembersBookStart,
module='association', type_='model')
Pool.register(Member,
Configuration,
MemberSequence,
Membership,
Period,
Fee,
Line,
Move,
GenerateFeeStart,
Cron,
PrintMembersBookStart,
module='association',
type_='model')
Pool.register(
PostFee,
GenerateFee,
MembersBookWizard,
module='association', type_='wizard')
Pool.register(PostFee,
GenerateFee,
MembersBookWizard,
module='association',
type_='wizard')
Pool.register(
MembersBookReport,
module='association', type_='report')
Pool.register(MembersBookReport, module='association', type_='report')
from trytond.pool import PoolMeta, Pool
from trytond.pool import PoolMeta
__all__ = ['Move']
class Move(metaclass=PoolMeta):
__name__ = 'account.move'
@classmethod
def _get_origin(cls):
return super(Move, cls)._get_origin() + ['association.membership.fee']
\ No newline at end of file
return super(Move, cls)._get_origin() + ['association.membership.fee']
from trytond import backend
from trytond.model import (ModelView, ModelSQL, ModelSingleton, fields)
from trytond.pyson import Eval
from trytond.modules.company.model import (CompanyMultiValueMixin, CompanyValueMixin)
from trytond.modules.company.model import (CompanyMultiValueMixin,
CompanyValueMixin)
from trytond.tools.multivalue import migrate_property
__all__ = ['Configuration', 'MemberSequence']
class Configuration(ModelSingleton, ModelSQL, ModelView, CompanyMultiValueMixin):
class Configuration(ModelSingleton, ModelSQL, ModelView,
CompanyMultiValueMixin):
"""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'),
]))
member_sequence = fields.MultiValue(
fields.Many2One('ir.sequence',
"Member Sequence",
required=True,
domain=[
('company', 'in',
[Eval('context', {}).get('company', -1), None]),
('code', '=', 'association.member'),
]))
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'])
@classmethod
def __register__(cls, module_name):
......@@ -45,6 +51,8 @@ class MemberSequence(ModelSQL, CompanyValueMixin):
field_names.append('member_sequence')
value_names.append('member_sequence')
fields.append('company')
migrate_property(
'association.configuration', field_names, cls, value_names,
fields=fields)
migrate_property('association.configuration',
field_names,
cls,
value_names,
fields=fields)
......@@ -29,7 +29,8 @@ 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,
......@@ -88,7 +89,6 @@ class Member(Workflow, ModelSQL, ModelView):
depends=['state'],
states={'readonly': Eval('state') != 'draft'})
@classmethod
def __setup__(cls):
super(Member, cls).__setup__()
......@@ -133,8 +133,8 @@ class Member(Workflow, ModelSQL, ModelView):
return Sequence.get_id(sequence.id)
@classmethod
def search_party_member(cls,name, clause):
return [('party',) + tuple(clause[1:])]
def search_party_member(cls, name, clause):
return [('party', ) + tuple(clause[1:])]
@classmethod
def create(cls, vlist):
......
......@@ -20,7 +20,7 @@ fee_amount = fields.Numeric("Fee Amount", fee_digit, required=True)
_STATES = {'readonly': Eval('state') != 'open'}
_LINE_STATES = {'readonly': Eval('member_state','') != 'draft'}
_LINE_STATES = {'readonly': Eval('member_state', '') != 'draft'}
_FEE_STATES = {'readonly': Bool(Eval('move'))}
......@@ -54,9 +54,7 @@ class Membership(ModelSQL, ModelView):
'account.journal',
'Journal',
ondelete='RESTRICT',
help=
"The accounting journal where the moves associated to this membership shold be stored"
)
help="The accounting journal that will be used for the fee")
account_revenue = fields.Many2One(
'account.account',
'Account Revenue',
......@@ -95,7 +93,6 @@ class Line(ModelSQL, ModelView):
'on_change_with_member_join_date')
member_leave_date = fields.Function(fields.Date("Member Leave Date"),
'on_change_with_member_leave_date')
member = fields.Many2One('association.member',
"Member",
states=_LINE_STATES,
......@@ -330,8 +327,18 @@ class Fee(ModelSQL, ModelView):
pool = Pool()
MoveLine = pool.get('account.move.line')
account = self.member.party.account_receivable if amount > 0 else self.period.membership.account_revenue
party = self.member.party if account.party_required else None
account = None
if amount > 0:
account = self.member.party.account_receivable
else:
account = self.period.membership.account_revenue
party = None
if account.party_required:
party = self.member.party
else:
party = None
return MoveLine(
debit=abs(amount) if amount > 0 else 0,
credit=abs(amount) if amount < 0 else 0,
......
import datetime
from dateutil.relativedelta import relativedelta
from proteus import Model, Wizard
from decimal import *
from proteus import Model
from decimal import Decimal
__all__ = ['create_period']
def create_period(start, end, membership, amount):
Period = Model.get('association.membership.period')
period = Period()
# period.membership = membership
period.start_date = start
period.end_date = end
period.amount = Decimal(amount)
period.membership = membership
period.name = "test"
period.save()
return period
\ No newline at end of file
return period
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