dp_script: pricelisten können jetzt richtig gesetzt werden

develop
Ahmed Aly 2017-11-28 17:59:15 +01:00
parent 644619d3c4
commit 3499d5aa29
2 changed files with 44 additions and 20 deletions

View File

@ -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,

View File

@ -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