Add timezone on company to compute today
issue3444 review1411002
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
* Add timezone on company to compute today
|
||||
|
||||
Version 3.0.0 - 2013-10-21
|
||||
* Bug fixes (see mercurial logs for details)
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ def register():
|
||||
Property,
|
||||
Sequence,
|
||||
SequenceStrict,
|
||||
Date,
|
||||
CompanyConfigStart,
|
||||
Cron,
|
||||
CronCompany,
|
||||
|
||||
+24
-2
@@ -8,9 +8,16 @@ from trytond.pyson import Eval, If
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
|
||||
try:
|
||||
import pytz
|
||||
TIMEZONES = [(x, x) for x in pytz.common_timezones]
|
||||
except ImportError:
|
||||
TIMEZONES = []
|
||||
TIMEZONES += [(None, '')]
|
||||
|
||||
__all__ = ['Company', 'Employee', 'UserEmployee', 'User', 'Property',
|
||||
'Sequence', 'SequenceStrict', 'CompanyConfigStart', 'CompanyConfig',
|
||||
'CompanyReport', 'LetterReport']
|
||||
'Sequence', 'SequenceStrict', 'Date', 'CompanyConfigStart',
|
||||
'CompanyConfig', 'CompanyReport', 'LetterReport']
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
|
||||
@@ -25,6 +32,7 @@ class Company(ModelSQL, ModelView):
|
||||
header = fields.Text('Header')
|
||||
footer = fields.Text('Footer')
|
||||
currency = fields.Many2One('currency.currency', 'Currency', required=True)
|
||||
timezone = fields.Selection(TIMEZONES, 'Timezone', translate=False)
|
||||
employees = fields.One2Many('company.employee', 'company', 'Employees')
|
||||
|
||||
@classmethod
|
||||
@@ -275,6 +283,20 @@ class SequenceStrict(Sequence):
|
||||
__name__ = 'ir.sequence.strict'
|
||||
|
||||
|
||||
class Date:
|
||||
__name__ = 'ir.date'
|
||||
|
||||
@classmethod
|
||||
def today(cls, timezone=None):
|
||||
pool = Pool()
|
||||
Company = pool.get('company.company')
|
||||
company_id = Transaction().context.get('company')
|
||||
if timezone is None and company_id:
|
||||
company = Company(company_id)
|
||||
timezone = pytz.timezone(company.timezone)
|
||||
return super(Date, cls).today(timezone=timezone)
|
||||
|
||||
|
||||
class CompanyConfigStart(ModelView):
|
||||
'Company Config'
|
||||
__name__ = 'company.company.config.start'
|
||||
|
||||
@@ -74,6 +74,9 @@ setup(name='trytond_company',
|
||||
],
|
||||
license='GPL-3',
|
||||
install_requires=requires,
|
||||
extras_require={
|
||||
'timezone': ['pytz'],
|
||||
},
|
||||
zip_safe=False,
|
||||
entry_points="""
|
||||
[trytond.modules]
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
<?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 string="Company">
|
||||
<form string="Company" col="6">
|
||||
<label name="party"/>
|
||||
<field name="party"/>
|
||||
<label name="currency"/>
|
||||
<field name="currency"/>
|
||||
<notebook colspan="4">
|
||||
<label name="timezone"/>
|
||||
<field name="timezone"/>
|
||||
<notebook colspan="6">
|
||||
<page string="Company" col="2" id="company">
|
||||
<label name="parent"/>
|
||||
<field name="parent"/>
|
||||
|
||||
Reference in New Issue
Block a user