@@ -1,3 +1,4 @@
|
||||
* Ask for date when creating move from template
|
||||
* Add receivable/payable to company
|
||||
|
||||
Version 6.8.0 - 2023-05-01
|
||||
|
||||
@@ -33,7 +33,6 @@ class MoveTemplate(DeactivableMixin, ModelSQL, ModelView):
|
||||
'company': Eval('company', -1),
|
||||
},
|
||||
depends={'company'})
|
||||
date = fields.Char('Date', help='Leave empty for today.')
|
||||
description = fields.Char('Description',
|
||||
help="Keyword values substitutions are identified "
|
||||
"by braces ('{' and '}').")
|
||||
@@ -55,8 +54,6 @@ class MoveTemplate(DeactivableMixin, ModelSQL, ModelView):
|
||||
move = Move()
|
||||
move.company = self.company
|
||||
move.journal = self.journal
|
||||
if self.date:
|
||||
move.date = values.get(self.date)
|
||||
if self.description:
|
||||
move.description = self.description.format(
|
||||
**dict(Keyword.format_values(self, values)))
|
||||
@@ -362,6 +359,7 @@ class CreateMove(Wizard):
|
||||
for keyword in template.keywords:
|
||||
values[keyword.name] = getattr(self.keywords, keyword.name, None)
|
||||
move = template.get_move(values)
|
||||
move.date = self.template.date
|
||||
move.period = self.template.period
|
||||
move.save()
|
||||
return move
|
||||
@@ -402,6 +400,7 @@ class CreateMoveTemplate(ModelView):
|
||||
domain=[
|
||||
('company', '=', Eval('context', {}).get('company', -1)),
|
||||
])
|
||||
date = fields.Date('Effective Date', required=True)
|
||||
period = fields.Many2One('account.period', 'Period', required=True,
|
||||
domain=[
|
||||
('state', '!=', 'close'),
|
||||
@@ -409,6 +408,12 @@ class CreateMoveTemplate(ModelView):
|
||||
Eval('context', {}).get('company', 0)),
|
||||
])
|
||||
|
||||
@classmethod
|
||||
def default_date(cls):
|
||||
pool = Pool()
|
||||
Date = pool.get('ir.date')
|
||||
return Date.today()
|
||||
|
||||
@classmethod
|
||||
def default_period(cls):
|
||||
pool = Pool()
|
||||
@@ -420,6 +425,39 @@ class CreateMoveTemplate(ModelView):
|
||||
return None
|
||||
return period.id
|
||||
|
||||
@fields.depends('date', 'period')
|
||||
def on_change_date(self):
|
||||
pool = Pool()
|
||||
Period = pool.get('account.period')
|
||||
company = Transaction().context.get('company')
|
||||
if self.date:
|
||||
if (not self.period
|
||||
or not (
|
||||
self.period.start_date <= self.date
|
||||
<= self.period.end_date)):
|
||||
try:
|
||||
self.period = Period.find(company, date=self.date)
|
||||
except PeriodNotFoundError:
|
||||
pass
|
||||
|
||||
@fields.depends('period', 'date')
|
||||
def on_change_period(self):
|
||||
pool = Pool()
|
||||
Date = pool.get('ir.date')
|
||||
today = Date.today()
|
||||
if self.period:
|
||||
start_date = self.period.start_date
|
||||
end_date = self.period.end_date
|
||||
if (not self.date
|
||||
or not (start_date <= self.date <= end_date)):
|
||||
if start_date <= today:
|
||||
if today <= end_date:
|
||||
self.date = today
|
||||
else:
|
||||
self.date = end_date
|
||||
else:
|
||||
self.date = start_date
|
||||
|
||||
|
||||
class CreateMoveKeywords(ModelView):
|
||||
'Create Move from Template'
|
||||
|
||||
@@ -4,6 +4,7 @@ Move Template Scenario
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime
|
||||
>>> from decimal import Decimal
|
||||
>>> from proteus import Model, Wizard
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
@@ -11,6 +12,7 @@ Imports::
|
||||
... get_company
|
||||
>>> from trytond.modules.account.tests.tools import create_fiscalyear, \
|
||||
... create_chart, get_accounts, create_tax, create_tax_code
|
||||
>>> today = datetime.date.today()
|
||||
|
||||
Activate modules::
|
||||
|
||||
@@ -93,6 +95,23 @@ Create Template::
|
||||
Create Move::
|
||||
|
||||
>>> create_move = Wizard('account.move.template.create')
|
||||
>>> create_move.form.date == today
|
||||
True
|
||||
>>> period = create_move.form.period
|
||||
>>> period.start_date <= today <= period.end_date
|
||||
True
|
||||
>>> index = fiscalyear.periods.index(create_move.form.period)
|
||||
>>> next_period = fiscalyear.periods[index + 1]
|
||||
>>> create_move.form.date = next_period.start_date
|
||||
>>> create_move.form.period == next_period
|
||||
True
|
||||
>>> prev_period = fiscalyear.periods[index - 1]
|
||||
>>> create_move.form.period = prev_period
|
||||
>>> create_move.form.date == prev_period.end_date
|
||||
True
|
||||
>>> create_move.form.period = next_period
|
||||
>>> create_move.form.date == next_period.start_date
|
||||
True
|
||||
>>> create_move.form.template = template
|
||||
>>> create_move.execute('keywords')
|
||||
>>> data = {}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<?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">
|
||||
<form>
|
||||
<label name="template"/>
|
||||
<field name="template" widget="selection"/>
|
||||
<field name="template" widget="selection" colspan="3"/>
|
||||
<label name="date"/>
|
||||
<field name="date"/>
|
||||
<label name="period"/>
|
||||
<field name="period"/>
|
||||
</form>
|
||||
|
||||
@@ -10,11 +10,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<page string="Template" id="template">
|
||||
<label name="company"/>
|
||||
<field name="company"/>
|
||||
<newline/>
|
||||
<label name="journal"/>
|
||||
<field name="journal"/>
|
||||
<label name="date"/>
|
||||
<field name="date"/>
|
||||
<label name="description"/>
|
||||
<field name="description" colspan="3"/>
|
||||
<field name="lines" colspan="4"/>
|
||||
|
||||
Reference in New Issue
Block a user