Browse Source

[RM] useless field

pull/614/head
archetipo 9 years ago
committed by Dave Lasley
parent
commit
7253a9a2b1
  1. 38
      auto_backup/model/backup_scheduler.py
  2. 8
      auto_backup/view/bkp_conf_view.xml

38
auto_backup/model/backup_scheduler.py

@ -48,48 +48,16 @@ def execute(connector, method, *args):
class DbBackup(models.Model): class DbBackup(models.Model):
_name = 'db.backup' _name = 'db.backup'
def get_connection_uri(self, host, port, secure=False):
uri = 'http://%s:%s' % (host, port)
if secure:
uri = 'https://%s:%s' % (host, port)
return uri
def get_connection(self, host, port, secure=False):
uri = self.get_connection_uri(host, port, secure)
return xmlrpclib.ServerProxy(uri + '/xmlrpc/db')
def get_db_list(self, host, port, secure=False):
conn = self.get_connection(host, port, secure)
db_list = execute(conn, 'list')
return db_list
@api.model @api.model
def _get_db_name(self): def _get_db_name(self):
return self.env.cr.dbname return self.env.cr.dbname
# Columns local server
host = fields.Char(
string='Host', default='localhost', size=100, required=True)
securehost = fields.Boolean(string='Secure Host')
port = fields.Char(
string='Port', default='8069', size=10, required=True)
name = fields.Char( name = fields.Char(
string='Database', size=100, required=True, string='Database', size=100, required=True,
default=_get_db_name, default=_get_db_name,
help='Database you want to schedule backups for' help='Database you want to schedule backups for'
) )
adminpassword = fields.Char(
string='Admin user Password',
help=(
"The password Admin password of Odoo Instance."
),
required=True
)
bkp_dir = fields.Char( bkp_dir = fields.Char(
string='Backup Directory', size=100, string='Backup Directory', size=100,
default='/odoo/backups', default='/odoo/backups',
@ -271,6 +239,9 @@ class DbBackup(models.Model):
# user made a typo in his path with multiple slashes # user made a typo in his path with multiple slashes
# (/odoo//backups/) it will be fixed by this regex. # (/odoo//backups/) it will be fixed by this regex.
pathToWriteTo = re.sub('/+', '/', pathToWriteTo) pathToWriteTo = re.sub('/+', '/', pathToWriteTo)
_logger.debug(
'Start to copy files..'
)
try: try:
srv.chdir(pathToWriteTo) srv.chdir(pathToWriteTo)
except IOError: except IOError:
@ -293,9 +264,6 @@ class DbBackup(models.Model):
pass pass
srv.chdir(pathToWriteTo) srv.chdir(pathToWriteTo)
# Loop over all files in the directory. # Loop over all files in the directory.
_logger.debug(
'Start to copy files...'
)
for f in os.listdir(dir): for f in os.listdir(dir):
fullpath = os.path.join(dir, f) fullpath = os.path.join(dir, f)
if os.path.isfile(fullpath): if os.path.isfile(fullpath):

8
auto_backup/view/bkp_conf_view.xml

@ -12,11 +12,7 @@
<separator col="2" string="Local backup configuration"/> <separator col="2" string="Local backup configuration"/>
</group> </group>
<group> <group>
<field name="host" colspan="2"/>
<field name="securehost" colspan="2"/>
<field name="name"/> <field name="name"/>
<field name="port"/>
<field name="adminpassword" password="True"/>
<field name="bkp_dir"/> <field name="bkp_dir"/>
<field name="autoremove"/> <field name="autoremove"/>
<field name="daystokeep" attrs="{'invisible': [('autoremove','=',False)]}"/> <field name="daystokeep" attrs="{'invisible': [('autoremove','=',False)]}"/>
@ -69,8 +65,6 @@
<field name="type">tree</field> <field name="type">tree</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="Backups"> <tree string="Backups">
<field name='host'/>
<field name='port'/>
<field name='name'/> <field name='name'/>
<field name='bkp_dir'/> <field name='bkp_dir'/>
<field name="autoremove"/> <field name="autoremove"/>
@ -85,8 +79,6 @@
<field name="type">search</field> <field name="type">search</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<search string="Search options"> <search string="Search options">
<field name='host'/>
<field name='port'/>
<field name='name'/> <field name='name'/>
<field name='bkp_dir'/> <field name='bkp_dir'/>
<field name="autoremove"/> <field name="autoremove"/>

Loading…
Cancel
Save