From 3499d5aa29ae77d5c1d435019e95cc655446fc68 Mon Sep 17 00:00:00 2001 From: Ahmed Aly Date: Tue, 28 Nov 2017 17:59:15 +0100 Subject: [PATCH] =?UTF-8?q?dp=5Fscript:=20pricelisten=20k=C3=B6nnen=20jetz?= =?UTF-8?q?t=20richtig=20gesetzt=20werden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup/lib/config.py | 2 +- setup/lib/functions.py | 62 +++++++++++++++++++++++++++++------------- 2 files changed, 44 insertions(+), 20 deletions(-) diff --git a/setup/lib/config.py b/setup/lib/config.py index fc492c3f..b18ceee9 100644 --- a/setup/lib/config.py +++ b/setup/lib/config.py @@ -49,7 +49,7 @@ class Config(): 'group_uom': True, # Verwende Mengeneinheiten 'group_discount_per_so_line': True, # Rabatt auf Verkaufszeilen 'multi_sales_price': True, # Mehrere Verkaufspreise pro Produkt - 'multi_sales_price_method': 'formula', + 'multi_sales_price_method': 'percentage', # [percentage] Multiple prices per product (e.g. customer segments, currencies) # [formula] rices computed from formulas (discounts, margins, roundings) 'module_sale_margin': False, diff --git a/setup/lib/functions.py b/setup/lib/functions.py index 6943e18b..5f6d6d98 100644 --- a/setup/lib/functions.py +++ b/setup/lib/functions.py @@ -6,6 +6,7 @@ import odoorpc from urllib.parse import urlparse + class DatenpolFunctions: def __init__(self, environment, config): self.env = environment @@ -40,8 +41,10 @@ class DatenpolFunctions: with open(self.config.dump_file, 'rb') as dump_file: self.odoo.db.restore(self.env.super_admin_pw, self.env.dbname, dump_file, True) except Exception: - raise Exception("Wiederherstellen der Datenbank fehlgeschlagen. Eventuell wurde './dp [env] dump' nicht ausgeführt.") - print("\nACHTUNG: Nicht vergessen './dp [env] anonym' auszuführen, sodass es zu keiner Kommunikation mit dem Produktivsystem kommt") + raise Exception( + "Wiederherstellen der Datenbank fehlgeschlagen. Eventuell wurde './dp [env] dump' nicht ausgeführt.") + print( + "\nACHTUNG: Nicht vergessen './dp [env] anonym' auszuführen, sodass es zu keiner Kommunikation mit dem Produktivsystem kommt") return True def drop_db(self): @@ -62,6 +65,24 @@ class DatenpolFunctions: res_settings = self.odoo.env['res.config.settings'] vals = res_settings.default_get([]) + if self.config.settings.get('multi_sales_price', False): + if self.config.settings.get('multi_sales_price_method', False) and self.config.settings.get( + 'multi_sales_price_method', False) == 'percentage': + self.config.settings.update({ + "group_sale_pricelist": True, + "group_product_pricelist": False, + "group_pricelist_item": True, + "sale_pricelist_setting": "formula", + }) + if self.config.settings.get('multi_sales_price_method', False) and self.config.settings.get( + 'multi_sales_price_method', False) == 'formula': + self.config.settings.update({ + "group_sale_pricelist": True, + "group_product_pricelist": True, + "group_pricelist_item": False, + "sale_pricelist_setting": "percentage", + }) + vals.update(self.config.settings) wizard_id = res_settings.create(vals) return res_settings.execute(wizard_id) @@ -151,12 +172,13 @@ class DatenpolFunctions: c = self.config # Standard Sales Tax sales_tax_ids = self.odoo.env['account.tax'].search( - [('name', '=', c.default_sales_tax)]) + [('name', '=', c.default_sales_tax)]) self.odoo.env['ir.default'].set('product.template', 'taxes_id', sales_tax_ids, company_id=self.company_id.id) # Standard Purchase Tax supplier_tax_ids = self.odoo.env['account.tax'].search( - [('name', '=', c.default_supplier_tax)]) - self.odoo.env['ir.default'].set('product.template', 'supplier_taxes_id', supplier_tax_ids, company_id=self.company_id.id) + [('name', '=', c.default_supplier_tax)]) + self.odoo.env['ir.default'].set('product.template', 'supplier_taxes_id', supplier_tax_ids, + company_id=self.company_id.id) return True def set_incoterms(self): @@ -192,7 +214,8 @@ class DatenpolFunctions: """Module installieren""" module_to_install = [module] if module else self.config.modules - mod_ids = self.odoo.env['ir.module.module'].search([('name', 'in', module_to_install), ('state', '!=', 'installed')]) + mod_ids = self.odoo.env['ir.module.module'].search( + [('name', 'in', module_to_install), ('state', '!=', 'installed')]) if not len(mod_ids) == 1 and raise_exception: raise Exception('Module %s not found or is not in state "uninstalled".' % module_to_install) self.odoo.env['ir.module.module'].button_immediate_install(mod_ids) @@ -255,7 +278,8 @@ class DatenpolFunctions: j_ids = self.odoo.env['account.journal'].search([('code', '=', 'Re.:')]) if len(j_ids) != 1: return False - journals = self.odoo.env['account.journal'].read(j_ids, ['refund_sequence', 'sequence_id', 'refund_sequence_id']) + journals = self.odoo.env['account.journal'].read(j_ids, + ['refund_sequence', 'sequence_id', 'refund_sequence_id']) # Rechnungsnummer if seq_dict.get('account.invoice', False): @@ -348,14 +372,14 @@ class DatenpolFunctions: # Mappings inaktiver Steuern löschen (also wenn rechte Seite eine inaktive Steuer ist, wie z. B "strf. i.g.L")) valid_position_ids = self.odoo.env['account.fiscal.position'].search( - [('name', 'in', c.valid_fiscal_positions)]) - #valid_tax_ids = self.odoo.env['account.tax'].search([('parent_id', '=', False)]) + [('name', 'in', c.valid_fiscal_positions)]) + # valid_tax_ids = self.odoo.env['account.tax'].search([('parent_id', '=', False)]) -# position_tax_line_ids = self.odoo.env['account.fiscal.position.tax'].search( - # [('position_id', 'in', valid_position_ids), - # ('tax_dest_id', 'not in', valid_tax_ids)]) - # vals = {'tax_dest_id': False} - # return self.odoo.env['account.fiscal.position.tax'].write(position_tax_line_ids, vals) + # position_tax_line_ids = self.odoo.env['account.fiscal.position.tax'].search( + # [('position_id', 'in', valid_position_ids), + # ('tax_dest_id', 'not in', valid_tax_ids)]) + # vals = {'tax_dest_id': False} + # return self.odoo.env['account.fiscal.position.tax'].write(position_tax_line_ids, vals) return True def update_module(self): @@ -402,7 +426,7 @@ class DatenpolFunctions: """Modul Upgrade abbrechen""" module_name = self.config.module_name mod_ids = self.odoo.env['ir.module.module'].search( - [('name', '=', module_name), ('state', '=', 'to upgrade')]) + [('name', '=', module_name), ('state', '=', 'to upgrade')]) if not len(mod_ids) == 1: raise Exception("Module '%s' not found or is not installed." % module_name) @@ -429,7 +453,7 @@ class DatenpolFunctions: for module_name in self.config.modules: mod_ids = self.odoo.env['ir.module.module'].search( - [('name', '=', module_name), ('state', '=', 'installed')]) + [('name', '=', module_name), ('state', '=', 'installed')]) if not len(mod_ids) == 1: raise Exception('Module "%s" not found or ist not installed.' % module_name) self.odoo.env['ir.module.module'].button_upgrade(mod_ids) @@ -441,7 +465,7 @@ class DatenpolFunctions: """Name des Zentrallagers setzen""" is_installed = self.odoo.env['ir.module.module'].search( - [('name', '=', 'stock'), ('state', '=', 'installed')]) + [('name', '=', 'stock'), ('state', '=', 'installed')]) if is_installed: vals = { 'name': self.config.warehouse_name or self.config.company_data.get('name', 'Mein Unternehmen'), @@ -583,7 +607,8 @@ class DatenpolFunctions: return False product_category_ids = self.odoo.env['product.category'].search([]) - return self.odoo.env['product.category'].write(product_category_ids, {'removal_strategy_id': strategy_ids[0]}) + return self.odoo.env['product.category'].write(product_category_ids, + {'removal_strategy_id': strategy_ids[0]}) return True def set_default_values(self): @@ -825,4 +850,3 @@ class DatenpolFunctions: if res_ids: return self.odoo.env['ir.translation'].unlink(res_ids) return True -