Skip to content

Commit

Permalink
⬆️1️⃣2️⃣ autostaging_base Port
Browse files Browse the repository at this point in the history
  • Loading branch information
Ommo73 committed Apr 1, 2019
1 parent 0f8de9c commit 7b49955
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 27 deletions.
50 changes: 47 additions & 3 deletions autostaging_base/README.rst
@@ -1,5 +1,49 @@
Autostaging (technical core)
============================
.. image:: https://img.shields.io/badge/license-LGPL--3-blue.png
:target: https://www.gnu.org/licenses/lgpl
:alt: License: LGPL-3

==================
Autostaging base
==================

Tested on Odoo 8.0 a0797d3b35cc235048e7947dd7a3d38e18c3e350
Change stages of records automatically after a specified time

The records which are not modified within the idle timeout automatically moved to the next stage

Credits
=======

Contributors
------------
* 'Ildar Nasyrov <iledarn@it-projects.info>'__

Sponsors
--------
* `IT-Projects LLC <https://it-projects.info>`__

Maintainers
-----------
* `IT-Projects LLC <https://it-projects.info>`__

To get a guaranteed support
you are kindly requested to purchase the module
at `odoo apps store <https://apps.odoo.com/apps/modules/12.0/autostaging_base/>`__.

Thank you for understanding!

`IT-Projects Team <https://www.it-projects.info/team>`__

Further information
===================

Demo: http://runbot.it-projects.info/demo/misc-addons/12.0

HTML Description: https://apps.odoo.com/apps/modules/12.0/autostaging_base/

Usage instructions: `<doc/index.rst>`_

Changelog: `<doc/changelog.rst>`_

Notifications on updates: `via Atom <https://github.com/it-projects-llc/misc-addons/commits/12.0/autostaging_base.atom>`_, `by Email <https://blogtrottr.com/?subscribe=https://github.com/it-projects-llc/misc-addons/commits/12.0/autostaging_base.atom>`_

Tested on Odoo 12.0 1e6f47ae56efe22101aa3db6159cd3cc16b9c120
1 change: 1 addition & 0 deletions autostaging_base/__init__.py
@@ -1 +1,2 @@
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).
from . import models
58 changes: 48 additions & 10 deletions autostaging_base/__manifest__.py
@@ -1,12 +1,50 @@
# Copyright 2015-2017 Ildar Nasyrov <https://it-projects.info/>
# Copyright 2018 Ruslan Ronzhin <https://it-projects.info/team/rusllan/>
# Copyright 2019 Artem Rafailov <https://it-projects.info/team/Ommo73/>
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).
{
'name': "Autostaging (technical core)",
'author': "IT-Projects LLC, Ildar Nasyrov",
'license': 'LGPL-3',
'website': "https://twitter.com/nasyrov_ildar",
'category': 'Autostaging',
'version': '1.0.0',
'data': [
'data.xml',
],
"installable": False
"name": """Autostaging (technical core)""",
"summary": """Change stages automatically after a specified time""",
"category": "Hidden",
# "live_test_url": "http://apps.it-projects.info/shop/product/DEMO-URL?version=12.0",
"images": [],
"version": "12.0.1.0.0",
"application": False,

"author": "IT-Projects LLC, Ildar Nasyrov",
"support": "apps@it-projects.info",
"website": "https://it-projects.info/",
"license": "LGPL-3",
# "price": 9.00,
# "currency": "EUR",

"depends": [
],
"external_dependencies": {"python": [], "bin": []},
"data": [
"data.xml",
],
"demo": [
],
"qweb": [
],

"post_load": None,
"pre_init_hook": None,
"post_init_hook": None,
"uninstall_hook": None,

"auto_install": False,
"installable": True,

# "demo_title": "{MODULE_NAME}",
# "demo_addons": [
# ],
# "demo_addons_hidden": [
# ],
# "demo_url": "DEMO-URL",
# "demo_summary": "{SHORT_DESCRIPTION_OF_THE_MODULE}",
# "demo_images": [
# "images/MAIN_IMAGE",
# ]
}
12 changes: 7 additions & 5 deletions autostaging_base/data.xml
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--Copyright 2015 Ildar Nasyrov <https://it-projects.info/>
Copyright 2019 Artem Rafailov <https://it-projects.info/team/Ommo73/>
License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).-->
<openerp>
<data>
<!-- Cron job for automatically move -->
<record forcecreate="True" id="ir_cron_autostaging"
<record id="ir_cron_autostaging" forcecreate="True"
model="ir.cron">
<field name="name">Autostaging</field>
<field eval="True" name="active" />
Expand All @@ -11,9 +13,9 @@
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall" />
<field eval="'autostaging.card'" name="model" />
<field eval="'_cron_move_cards'" name="function" />
<field eval="'()'" name="args" />
<field name="model_id" ref="model_autostaging_card"/>
<field name="state">code</field>
<field name="code">model._cron_move_cards()</field>
</record>
</data>
</openerp>
7 changes: 7 additions & 0 deletions autostaging_base/doc/changelog.rst
@@ -0,0 +1,7 @@
Changelog
=========

`1.0.0`
-------

- Init version
8 changes: 8 additions & 0 deletions autostaging_base/doc/index.rst
@@ -0,0 +1,8 @@
==================
Autostaging base
==================

Installation
============

* `Install <https://odoo-development.readthedocs.io/en/latest/odoo/usage/install-module.html>`__ this module in a usual way
21 changes: 12 additions & 9 deletions autostaging_base/models.py
@@ -1,9 +1,13 @@

from openerp import models, fields, api
# Copyright 2015 Ildar Nasyrov <https://it-projects.info/>
# Copyright 2016 x620 <https://github.com/x620>
# Copyright 2017-2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2019 Artem Rafailov <https://it-projects.info/team/Ommo73/>
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).
from odoo import models, fields, api
import datetime
import time
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
from openerp.exceptions import ValidationError
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
from odoo.exceptions import ValidationError
from odoo.tools.translate import _


Expand Down Expand Up @@ -67,10 +71,9 @@ def _compute_enabled_one(self):
@api.multi
def _get_autostaging_date(self):
self.ensure_one()

delta = datetime.timedelta(days=getattr(self, self._field_stage_id).autostaging_idle_timeout)
return (datetime.datetime.strptime(
self.write_date, DEFAULT_SERVER_DATETIME_FORMAT) + delta).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
str(self.write_date)[:-7], DEFAULT_SERVER_DATETIME_FORMAT) + delta).strftime(DEFAULT_SERVER_DATETIME_FORMAT)

@api.multi
def _update_autostaging_date(self):
Expand Down Expand Up @@ -112,7 +115,7 @@ def _compute_autostaging_days_left_one(self):

def _get_model_list(self):
res = []
for r in self.env['ir.model.fields'].search([('name', '=', 'next_stage_related')]):
for r in self.env['ir.model.fields'].search([('name', '=', 'autostaging_card_next_stage')]):
res.append(r.model_id.model)
return res

Expand All @@ -128,9 +131,9 @@ def _move_cards(self):
(self._field_folder_id, '=', False),
'&', '&',
((self._field_stage_id + '.autostaging_enabled'), '=', True),
((self._field_stage_id + '.next_stage'), '!=', False),
((self._field_stage_id + '.autostaging_next_stage'), '!=', False),
('autostaging_date', '<=', time.strftime('%Y-%m-%d'))]
cards = self.search(domain)
for card in cards:
card.with_context(autostaging=True).write(
{self._field_stage_id: getattr(card, self._field_stage_id).next_stage.id})
{self._field_stage_id: getattr(card, self._field_stage_id).autostaging_next_stage.id})
Binary file modified autostaging_base/static/description/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7b49955

Please sign in to comment.