Make period's post_move_sequence optional

review605004
issue2916
This commit is contained in:
Albert Cervera i Areny
2013-01-22 16:14:24 +01:00
parent 87222daf32
commit f9cf118e9d
4 changed files with 21 additions and 6 deletions
+1
View File
@@ -1,3 +1,4 @@
* Make period's post_move_sequence optional and use fiscal year's one if empty
* Add sale, purchase or other kind on Tax Rule and Tax Group
Version 2.6.0 - 2012-10-22
-1
View File
@@ -167,7 +167,6 @@ class FiscalYear(ModelSQL, ModelView):
'start_date': period_start_date,
'end_date': period_end_date,
'fiscalyear': fiscalyear.id,
'post_move_sequence': fiscalyear.post_move_sequence.id,
'type': 'standard',
})
period_start_date = period_end_date + relativedelta(days=1)
+1 -1
View File
@@ -364,7 +364,7 @@ class Move(ModelSQL, ModelView):
if not move.post_number:
values['post_date'] = Date.today()
values['post_number'] = Sequence.get_id(
move.period.post_move_sequence.id)
move.period.post_move_sequence_used.id)
cls.write([move], values)
@classmethod
+19 -4
View File
@@ -6,6 +6,7 @@ from trytond.pyson import Eval
from trytond.transaction import Transaction
from trytond.pool import Pool
from trytond.const import OPERATORS
from trytond.backend import TableHandler
__all__ = ['Period', 'ClosePeriod', 'ReOpenPeriod']
@@ -31,10 +32,8 @@ class Period(ModelSQL, ModelView):
('close', 'Close'),
], 'State', readonly=True, required=True)
post_move_sequence = fields.Many2One('ir.sequence', 'Post Move Sequence',
required=True, domain=[('code', '=', 'account.move')],
context={'code': 'account.move'}, states={
'required': False,
})
domain=[('code', '=', 'account.move')],
context={'code': 'account.move'})
type = fields.Selection([
('standard', 'Standard'),
('adjustment', 'Adjustment'),
@@ -43,6 +42,16 @@ class Period(ModelSQL, ModelView):
company = fields.Function(fields.Many2One('company.company', 'Company',),
'get_company', searcher='search_company')
@classmethod
def __register__(cls, module_name):
cursor = Transaction().cursor
super(Period, cls).__register__(module_name)
table = TableHandler(cursor, cls, module_name)
# Migration from 2.6: post_move_sequence is no longer required
table.not_null_action('post_move_sequence', 'remove')
@classmethod
def __setup__(cls):
super(Period, cls).__setup__()
@@ -111,6 +120,8 @@ class Period(ModelSQL, ModelView):
or self.end_date > self.fiscalyear.end_date)
def check_post_move_sequence(self):
if not self.post_move_sequence:
return True
if self.search([
('post_move_sequence', '=', self.post_move_sequence.id),
('fiscalyear', '!=', self.fiscalyear.id),
@@ -257,6 +268,10 @@ class Period(ModelSQL, ModelView):
'state': 'open',
})
@property
def post_move_sequence_used(self):
return self.post_move_sequence or self.fiscalyear.post_move_sequence
class ClosePeriod(Wizard):
'Close Period'