Browse Source

Rename module

From rusty_record_reaper_runner to record_archiver.
Not that I dislike the old funny name, but I guess it will be easier to get
what it does with the new (maybe too serious) name.
pull/196/head
Guewen Baconnier 10 years ago
parent
commit
4239e84ea6
  1. 0
      record_archiver/__init__.py
  2. 13
      record_archiver/__openerp__.py
  3. 6
      record_archiver/data/cron.xml
  4. 0
      record_archiver/models/__init__.py
  5. 0
      record_archiver/models/company.py
  6. 24
      record_archiver/models/record_lifespan.py
  7. 8
      record_archiver/models/res_config.py
  8. 0
      record_archiver/static/src/img/icon.png
  9. 24
      record_archiver/views/res_config.xml

0
rusty_record_reaper_runner/__init__.py → record_archiver/__init__.py

13
rusty_record_reaper_runner/__openerp__.py → record_archiver/__openerp__.py

@ -17,17 +17,18 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
{'name': 'Rusty Record Reaper Runner',
{'name': 'Records Archiver',
'version': '0.1',
'description': """
Define a cron job to deactivate old records in order to optimize performances.
Create a cron job that deactivates old records in order to optimize
performance.
Records are deactivated base on last activity on them (write_date).
Records are deactivated based on their last activity (write_date).
You can configure lifespan of each type of record in
Settings -> Configuration -> Rusty Record Reaper Runner
You can configure lifespan of each type of record in
`Settings -> Configuration -> Records Archiver`
Lifespan is defined per record per company.
Lifespan is defined per record per company.
""",
'author': 'Camptocamp',
'maintainer': 'Camptocamp',

6
rusty_record_reaper_runner/data/cron.xml → record_archiver/data/cron.xml

@ -2,8 +2,8 @@
<openerp>
<data noupdate="1">
<record forcecreate="True" id="ir_cron_rusty_record_reaper_runner" model="ir.cron">
<field name="name">Rusty Record Reaper Runner</field>
<record forcecreate="True" id="ir_cron_record_archiver" model="ir.cron">
<field name="name">Records Archiver</field>
<field eval="True" name="active"/>
<field name="user_id" ref="base.user_root"/>
<field name="interval_number">1</field>
@ -11,7 +11,7 @@
<field name="numbercall">-1</field>
<field eval="False" name="doall"/>
<field eval="'record.lifespan'" name="model"/>
<field eval="'_scheduler_rusty_record_reaper'" name="function"/>
<field eval="'_scheduler_record_archiver'" name="function"/>
<field eval="'()'" name="args"/>
</record>

0
rusty_record_reaper_runner/models/__init__.py → record_archiver/models/__init__.py

0
rusty_record_reaper_runner/models/company.py → record_archiver/models/company.py

24
rusty_record_reaper_runner/models/record_lifespan.py → record_archiver/models/record_lifespan.py

@ -29,9 +29,10 @@ _logger = logging.getLogger(__name__)
class RecordLifespan(orm.Model):
"""Instead of writing this info on ir.model
here is a new object to be able to configure rec lifespan
per company
""" Configure records lifespans per model
After the lifespan is expired (compared to the `write_date` of the
records), the records are deactivated.
"""
_name = 'record.lifespan'
@ -45,7 +46,7 @@ class RecordLifespan(orm.Model):
"Months",
required=True,
help="Number of month after which the records will be set to "
"inactive based on write date"),
"inactive based on their write date"),
'company_id': fields.many2one(
'res.company',
string="Company",
@ -60,30 +61,27 @@ class RecordLifespan(orm.Model):
"Months must be a value greater than 0"),
]
def _scheduler_rusty_record_reaper(self, cr, uid, context=None):
def _scheduler_record_archiver(self, cr, uid, context=None):
lifespan_ids = self.search(cr, uid, [], context=context)
_logger.info('Record Reaper starts harvesting rusty records')
_logger.info('Records archiver starts archiving records')
for lifespan_id in lifespan_ids:
try:
self.harvest_rusty_records(
cr, uid, [lifespan_id], context=context)
self.archive_records(cr, uid, [lifespan_id], context=context)
except osv.except_osv as e:
_logger.error("Reaper error:\n%s", e[1])
_logger.error("Archiver error:\n%s", e[1])
_logger.info('Rusty Records now rest in peace')
return True
def harvest_rusty_records(self, cr, uid, ids, context=None):
def archive_records(self, cr, uid, ids, context=None):
""" Search and deactivate old records for each configured lifespan
Only done and cancelled records will be deactivated.
"""
if context is None:
context = {}
lifespans = self.browse(cr, uid, ids, context=context)
today = datetime.today()
for lifespan in lifespans:
model = self.pool.get(lifespan.model)
model = self.pool[lifespan.model]
if not model:
raise osv.except_osv(
_('Error'),

8
rusty_record_reaper_runner/models/res_config.py → record_archiver/models/res_config.py

@ -23,8 +23,8 @@ from openerp.osv import orm, fields
_logger = logging.getLogger(__name__)
class RustyRecordReaperRunnerConfigSettings(orm.TransientModel):
_name = 'rusty.record.reaper.runner.config.settings'
class RecordArchiverConfigSettings(orm.TransientModel):
_name = 'record.archiver.config.settings'
_inherit = 'res.config.settings'
_columns = {
@ -45,8 +45,8 @@ class RustyRecordReaperRunnerConfigSettings(orm.TransientModel):
}
def create(self, cr, uid, values, context=None):
rec_id = super(RustyRecordReaperRunnerConfigSettings, self
).create(cr, uid, values, context=context)
_super = super(RecordArchiverConfigSettings, self)
rec_id = _super.create(cr, uid, values, context=context)
# Hack: to avoid some nasty bug, related fields are not written upon
# record creation.
# Hence we write on those fields here.

0
rusty_record_reaper_runner/static/src/img/icon.png → record_archiver/static/src/img/icon.png

Before

Width: 55  |  Height: 65  |  Size: 5.7 KiB

After

Width: 55  |  Height: 65  |  Size: 5.7 KiB

24
rusty_record_reaper_runner/views/res_config.xml → record_archiver/views/res_config.xml

@ -2,11 +2,11 @@
<openerp>
<data>
<record id="view_rusty_record_reaper_runner_config_settings" model="ir.ui.view">
<field name="name">rusty record reaper runner settings</field>
<field name="model">rusty.record.reaper.runner.config.settings</field>
<record id="view_record_archiver_config_settings" model="ir.ui.view">
<field name="name">record archiver settings</field>
<field name="model">record.archiver.config.settings</field>
<field name="arch" type="xml">
<form string="Configure Rusty Reacord Reaper Runner" version="7.0" class="oe_form_configuration">
<form string="Configure Records Archiver" version="7.0" class="oe_form_configuration">
<header>
<button string="Apply" type="object" name="execute" class="oe_highlight"/>
or
@ -24,8 +24,10 @@
</div>
</div>
</group>
<separator string="Record life span"/>
All following type of record will be harvested by the cron based on write_date. If a record has made his time, it will be deactivated.
<separator string="Record lifespan"/>
All following type of record will be harvested by the cron
based on write_date. If a record has made his time, it will be
deactivated.
<group>
<div>
<div>
@ -42,17 +44,17 @@
</field>
</record>
<record id="action_rusty_record_reaper_runner_config" model="ir.actions.act_window">
<field name="name">Configure Rusty Record Reaper Runner</field>
<record id="action_record_archiver_config" model="ir.actions.act_window">
<field name="name">Configure Records Archiver</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">rusty.record.reaper.runner.config.settings</field>
<field name="res_model">record.archiver.config.settings</field>
<field name="view_mode">form</field>
<field name="target">inline</field>
</record>
<menuitem id="menu_rusty_record_reaper_runner_config" name="Rusty Record Reaper Runner"
<menuitem id="menu_record_archiver__config" name="Records Archiver"
parent="base.menu_config"
sequence="70" action="action_rusty_record_reaper_runner_config"/>
sequence="70" action="action_record_archiver_config"/>
</data>
</openerp>
Loading…
Cancel
Save