def migrate(env, version): _update_no_update_ir_cron(env) if parse_version(version) < parse_version('12.0.2.0.0'): # We check the version here as this post-migration script was in # 12.0.2.0.0 and already done for those who used the module when # it was a PR _init_last_date_invoiced_on_contract_lines(env) _init_invoicing_partner_id_on_contracts(env)
def migrate(cr, version): if parse_version(version) == parse_version('12.0.2.0.0'): # pre-paid/post-paid becomes significant for monthlylastday too, # make sure it has the value that was implied for previous versions. cr.execute("""\ UPDATE product_template SET recurring_invoicing_type = 'post-paid' WHERE recurring_rule_type = 'monthlylastday' """)
def migrate(env, version): if parse_version(version) == parse_version("14.0.1.0.0"): openupgrade.rename_fields(env, field_renames) if openupgrade.table_exists(env.cr, "base_comment_template_res_partner_rel"): # Swap column names, as they were incorrect env.cr.execute("ALTER TABLE base_comment_template_res_partner_rel " "RENAME base_comment_template_id TO temp") env.cr.execute("ALTER TABLE base_comment_template_res_partner_rel " "RENAME res_partner_id TO base_comment_template_id") env.cr.execute("ALTER TABLE base_comment_template_res_partner_rel " "RENAME temp TO res_partner_id")
def test_pylint(self): if pylint is None: self._skip_test('please install pylint') required_pylint_version = tools.parse_version('1.6.4') if sys.version_info >= (3, 6): required_pylint_version = tools.parse_version('1.7.0') if tools.parse_version(getattr(pylint, '__version__', '0.0.1')) < required_pylint_version: self._skip_test('please upgrade pylint to >= %s' % required_pylint_version) paths = [tools.config['root_path']] for module in get_modules(): module_path = get_module_path(module) if not module_path.startswith( join(tools.config['root_path'], 'addons')): paths.append(module_path) options = [ '--rcfile=%s' % os.devnull, '--disable=all', '--enable=%s' % ','.join(self.ENABLED_CODES), '--reports=n', "--msg-template='{msg} ({msg_id}) at {path}:{line}'", '--load-plugins=pylint.extensions.bad_builtin,_odoo_checker_sql_injection,_odoo_checker_gettext,_odoo_checker_unlink_override', '--bad-functions=%s' % ','.join(self.BAD_FUNCTIONS), '--deprecated-modules=%s' % ','.join(self.BAD_MODULES) ] pypath = HERE + os.pathsep + os.environ.get('PYTHONPATH', '') env = dict(os.environ, PYTHONPATH=pypath) try: pylint_bin = tools.which('pylint') process = subprocess.Popen( [pylint_bin] + options + paths, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, ) except (OSError, IOError): self._skip_test('pylint executable not found in the path') else: out, err = process.communicate() if process.returncode: self.fail("pylint test failed:\n" + (b"\n" + out + b"\n" + err).decode('utf-8').strip())
def migrate(env, version): if parse_version(version) == parse_version("14.0.1.0.0"): openupgrade.logged_query( env.cr, """ INSERT INTO base_comment_template_res_partner_rel (res_partner_id, base_comment_template_id) SELECT SPLIT_PART(ip.res_id, ',', 2)::int AS res_partner_id, SPLIT_PART(ip.value_reference, ',', 2)::int AS base_comment_template_id FROM ir_property ip JOIN ir_model_fields imf ON ip.fields_id = imf.id JOIN res_partner rp ON rp.id = SPLIT_PART(ip.res_id, ',', 2)::int JOIN base_comment_template bct ON bct.id = SPLIT_PART(ip.value_reference, ',', 2)::int WHERE imf.name = 'property_comment_template_id' AND imf.model = 'res.partner' AND ip.res_id IS NOT NULL ON CONFLICT DO NOTHING """, )
def write(self, values): """ Warn the user about updating account if they try to install account_reports with an out of date module A change in stable added a dependency between account_reports and a template update in account. It could cause a traceback when updating account_reports, or account_accountant with an out of date account module. This will inform the user about what to do in such case, by asking him to update invoicing. """ mod_names = self.mapped('name') new_state = values.get('state') if new_state in ( 'to upgrade', 'to install' ) and 'account_reports' in mod_names and 'account' not in mod_names: invoicing_mod = self.env.ref('base.module_account') # Do not install or update account_report if account version is not >= 1.2, and we are not also installing/updating it if parse_version(invoicing_mod.latest_version) < parse_version( f'{series}.1.2') and invoicing_mod.state not in ( 'to install', 'to upgrade'): raise UserError( _("Please update the Invoicing module before continuing.")) return super().write(values)
# noqa try: import odoo.release as release import odoo.tools.parse_version as parse_version except (AttributeError, ImportError): import openerp.release as release import openerp.tools.parse_version as parse_version if parse_version(release.version) > parse_version("9.0c"): import odoo.addons.addon1 # noqa else: import openerp.addons.addon1 # noqa
wkhtmltopdf_state = 'install' wkhtmltopdf_dpi_zoom_ratio = False try: process = subprocess.Popen([_get_wkhtmltopdf_bin(), '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) except (OSError, IOError): _logger.info('You need Wkhtmltopdf to print a pdf version of the reports.') else: _logger.info('Will use the Wkhtmltopdf binary at %s' % _get_wkhtmltopdf_bin()) out, err = process.communicate() match = re.search(b'([0-9.]+)', out) if match: version = match.group(0).decode('ascii') if parse_version(version) < parse_version('0.12.0'): _logger.info('Upgrade Wkhtmltopdf to (at least) 0.12.0') wkhtmltopdf_state = 'upgrade' else: wkhtmltopdf_state = 'ok' if parse_version(version) >= parse_version('0.12.2'): wkhtmltopdf_dpi_zoom_ratio = True if config['workers'] == 1: _logger.info( 'You need to start Odoo with at least two workers to print a pdf version of the reports.' ) wkhtmltopdf_state = 'workers' else: _logger.info('Wkhtmltopdf seems to be broken.') wkhtmltopdf_state = 'broken'