Merge branch 'develop' of ssh://gitlab.datenpol.at:122/odoo/tz-austria into develop
						commit
						ad0b16dfc6
					
				|  | @ -4,3 +4,4 @@ | ||||||
| .settings | .settings | ||||||
| .idea | .idea | ||||||
| *.swp | *.swp | ||||||
|  | tza36 | ||||||
|  | @ -0,0 +1,17 @@ | ||||||
|  | [options] | ||||||
|  | 
 | ||||||
|  | xmlrpc_port = 8080 | ||||||
|  | ; This is the password that allows database operations: | ||||||
|  | ; admin_passwd = admin | ||||||
|  | db_host = localhost | ||||||
|  | db_port = 5432 | ||||||
|  | db_user = tzaustria | ||||||
|  | db_password = x | ||||||
|  | 
 | ||||||
|  | addons_path = ext/odoo/addons,ext/custom-addons,ext/3rd-party-addons | ||||||
|  | ; For enterprise use the addons path bellow | ||||||
|  | ; addons_path = ext/enterprise-addons,ext/odoo/addons,ext/3rd-party-addons,ext/custom-addons,dmi/run1 | ||||||
|  | timezone = Europe/Vienna | ||||||
|  | 
 | ||||||
|  | #dbfilter_test = ['.*',] | ||||||
|  | show_debug = 1 | ||||||
|  | @ -12,5 +12,4 @@ | ||||||
|         <field name="code">model.cron_get_changelog() |         <field name="code">model.cron_get_changelog() | ||||||
|         </field> |         </field> | ||||||
|     </record> |     </record> | ||||||
| 
 |  | ||||||
| </odoo> | </odoo> | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ | ||||||
| 
 | 
 | ||||||
| from subprocess import check_output | from subprocess import check_output | ||||||
| import pytz | import pytz | ||||||
|  | import os | ||||||
| 
 | 
 | ||||||
| from odoo import models, fields, api, tools | from odoo import models, fields, api, tools | ||||||
| 
 | 
 | ||||||
|  | @ -20,35 +21,65 @@ class ChangeLog(models.Model): | ||||||
|         tz_name = self.env.context.get('tz') or tools.config.get('timezone') |         tz_name = self.env.context.get('tz') or tools.config.get('timezone') | ||||||
|         date_string = fields.datetime.now().strftime("%Y-%m-%d %H:%M:%S") |         date_string = fields.datetime.now().strftime("%Y-%m-%d %H:%M:%S") | ||||||
|         date_string = fields.Datetime.to_string( |         date_string = fields.Datetime.to_string( | ||||||
|             pytz.timezone('UTC').localize(fields.Datetime.from_string(date_string), is_dst=None).astimezone( |             pytz.timezone('UTC').localize(fields.Datetime.from_string(date_string), | ||||||
|  |                                           is_dst=None).astimezone( | ||||||
|                 pytz.timezone(tz_name))) |                 pytz.timezone(tz_name))) | ||||||
|         return 'Changelog ' + date_string[:-3] |         return 'Changelog ' + date_string[:-3] | ||||||
| 
 | 
 | ||||||
|     name = fields.Char('Name', required=True, default=_get_changelog_name) |     name = fields.Char('Name', required=True, default=_get_changelog_name) | ||||||
|     date = fields.Date('Datum', required=True, default=lambda *a: fields.datetime.now()) |     date = fields.Datetime('Timestamp', required=True, default=lambda *a: fields.datetime.now()) | ||||||
|     commit = fields.Char('Commit') |     commit = fields.Char('Commit') | ||||||
|     changelogs = fields.Text('Changelogs') |     changelogs = fields.Text('Changelogs') | ||||||
|  |     ppid = fields.Char('letzte ppid') | ||||||
| 
 | 
 | ||||||
|     @api.model |     @api.model | ||||||
|     def cron_get_changelog(self): |     def cron_get_changelog(self): | ||||||
|         vals = self._get_changelogs_vals() |         vals = self._get_changelogs_vals() | ||||||
|  |         changelog = False | ||||||
|  |         if vals: | ||||||
|             changelog = self.create(vals) |             changelog = self.create(vals) | ||||||
|         return changelog |         return changelog | ||||||
| 
 | 
 | ||||||
|     @api.model |     @api.model | ||||||
|     def _get_changelogs_vals(self): |     def _get_changelogs_vals(self): | ||||||
|         commit = check_output(["git", "log", "--pretty=oneline", "-1"]) |         commit = check_output(["git", "log", "--pretty=oneline", "-1"]) | ||||||
|         commit1 = self.search([], limit=1) |         last_commit = self.search([], limit=1) | ||||||
|         com2 = commit.decode("utf-8") |         com2 = commit.decode("utf-8") | ||||||
|         com2 = com2.split(' ')[0] |         com2 = com2.split(' ')[0] | ||||||
|         new_logs = b'' |         new_logs = b'' | ||||||
|         if commit1: |         if last_commit: | ||||||
|             com1 = commit1.commit |             com1 = last_commit.commit | ||||||
|             changelogs = check_output(["git", "log", "--pretty=oneline", com1 + "..." + com2]) |             changelogs = check_output(["git", "log", "--pretty=oneline", com1 + "..." + com2]) | ||||||
|             new_logs = b'' |  | ||||||
|             for changelog in changelogs.splitlines(): |             for changelog in changelogs.splitlines(): | ||||||
|                 new_logs += b' '.join(changelog.split(b' ')[1:]) + b'\n' |                 new_logs += b' '.join(changelog.split(b' ')[1:]) + b'\n' | ||||||
|         return { |         if new_logs == b'': | ||||||
|  |             vals = {} | ||||||
|  |         else: | ||||||
|  |             vals = { | ||||||
|                 'commit': com2, |                 'commit': com2, | ||||||
|             'changelogs': new_logs |                 'changelogs': new_logs, | ||||||
|  |                 'ppid': last_commit.ppid | ||||||
|             } |             } | ||||||
|  |         return vals | ||||||
|  | 
 | ||||||
|  |     @api.model | ||||||
|  |     def _get_reboot_vals(self): | ||||||
|  |         last_commit = self.search([], limit=1) | ||||||
|  |         if last_commit and last_commit.ppid != str(os.getppid()): | ||||||
|  |             vals = { | ||||||
|  |                 'commit': last_commit.commit, | ||||||
|  |                 'changelogs': 'Reboot', | ||||||
|  |                 'ppid': str(os.getppid()) | ||||||
|  |             } | ||||||
|  |             return vals | ||||||
|  | 
 | ||||||
|  |     @api.model_cr | ||||||
|  |     def _register_hook(self): | ||||||
|  |         try: | ||||||
|  |             self.cron_get_changelog() | ||||||
|  |             vals = self._get_reboot_vals() | ||||||
|  |             if vals: | ||||||
|  |                 self.create(vals) | ||||||
|  |         except: | ||||||
|  |             # falls git nicht vorhanden ist wird sicher eine Fehler ausgegeben. | ||||||
|  |             pass | ||||||
|  |  | ||||||
|  | @ -10,6 +10,7 @@ | ||||||
|                     <field name="name"/> |                     <field name="name"/> | ||||||
|                     <field name="date"/> |                     <field name="date"/> | ||||||
|                     <field name="commit"/> |                     <field name="commit"/> | ||||||
|  |                     <field name="ppid"/> | ||||||
|                 </group> |                 </group> | ||||||
|                 <group name="changelogs"> |                 <group name="changelogs"> | ||||||
|                     <field name="changelogs"/> |                     <field name="changelogs"/> | ||||||
|  | @ -27,6 +28,7 @@ | ||||||
|                 <field name="name"/> |                 <field name="name"/> | ||||||
|                 <field name="date"/> |                 <field name="date"/> | ||||||
|                 <field name="commit"/> |                 <field name="commit"/> | ||||||
|  |                 <field name="ppid"/> | ||||||
|                 <field name="changelogs"/> |                 <field name="changelogs"/> | ||||||
|             </tree> |             </tree> | ||||||
|         </field> |         </field> | ||||||
|  |  | ||||||
|  | @ -0,0 +1,40 @@ | ||||||
|  | Babel==2.3.4 | ||||||
|  | decorator==4.0.10 | ||||||
|  | docutils==0.12 | ||||||
|  | ebaysdk==2.1.5 | ||||||
|  | feedparser==5.2.1 | ||||||
|  | gevent>=1.1.2 | ||||||
|  | greenlet>=0.4.10 | ||||||
|  | html2text==2016.9.19 | ||||||
|  | Jinja2==2.8 | ||||||
|  | lxml>=3.5.0 | ||||||
|  | Mako==1.0.4 | ||||||
|  | MarkupSafe==0.23 | ||||||
|  | mock==2.0.0 | ||||||
|  | num2words==0.5.4 | ||||||
|  | ofxparse==0.16 | ||||||
|  | passlib==1.6.5 | ||||||
|  | Pillow>=3.4.1 | ||||||
|  | psutil>=4.3.1 | ||||||
|  | psycopg2==2.7.1 | ||||||
|  | pydot==1.2.3 | ||||||
|  | #pyldap==2.4.28 | ||||||
|  | pyparsing==2.1.10 | ||||||
|  | PyPDF2==1.26.0 | ||||||
|  | pyserial==3.1.1 | ||||||
|  | python-dateutil==2.5.3 | ||||||
|  | pytz==2016.7 | ||||||
|  | pyusb==1.0.0 | ||||||
|  | PyYAML==3.12 | ||||||
|  | qrcode==5.3 | ||||||
|  | reportlab>=3.3.0 | ||||||
|  | requests==2.11.1 | ||||||
|  | six==1.10.0 | ||||||
|  | suds-jurko==0.6 | ||||||
|  | vatnumber==1.2 | ||||||
|  | vobject==0.9.3 | ||||||
|  | Werkzeug==0.11.11 | ||||||
|  | XlsxWriter==0.9.3 | ||||||
|  | xlwt==1.3.* | ||||||
|  | xlrd==1.0.0 | ||||||
|  | odoorpc==0.6.0 | ||||||
|  | @ -26,6 +26,7 @@ ENVIRONMENTS = { | ||||||
|     # Local environments are listed with passwords |     # Local environments are listed with passwords | ||||||
|     'br': Environment('http://localhost', '8080', 'tz-austria_1', 'admin', 'x', 'admin'), |     'br': Environment('http://localhost', '8080', 'tz-austria_1', 'admin', 'x', 'admin'), | ||||||
|     'aa': Environment('http://localhost', '8080', 'tz-austria_1', 'admin', 'x', 'admin'), |     'aa': Environment('http://localhost', '8080', 'tz-austria_1', 'admin', 'x', 'admin'), | ||||||
|  |     'oa': Environment('http://localhost', '8080', 'tz-austria_1', 'admin', 'x', 'admin'), | ||||||
| 
 | 
 | ||||||
|     # Remote environments are always listed without passwords! |     # Remote environments are always listed without passwords! | ||||||
|     # Do not store them here, you have to type them anyway! |     # Do not store them here, you have to type them anyway! | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue