dp_script: pricelisten können jetzt richtig gesetzt werden
							parent
							
								
									644619d3c4
								
							
						
					
					
						commit
						3499d5aa29
					
				|  | @ -49,7 +49,7 @@ class Config(): | ||||||
|             'group_uom': True,                             # Verwende Mengeneinheiten |             'group_uom': True,                             # Verwende Mengeneinheiten | ||||||
|             'group_discount_per_so_line': True,            # Rabatt auf Verkaufszeilen |             'group_discount_per_so_line': True,            # Rabatt auf Verkaufszeilen | ||||||
|             'multi_sales_price': True,                      # Mehrere Verkaufspreise pro Produkt |             '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) |                                                         # [percentage] Multiple prices per product (e.g. customer segments, currencies) | ||||||
|                                                         # [formula] rices computed from formulas (discounts, margins, roundings) |                                                         # [formula] rices computed from formulas (discounts, margins, roundings) | ||||||
|             'module_sale_margin': False, |             'module_sale_margin': False, | ||||||
|  |  | ||||||
|  | @ -6,6 +6,7 @@ import odoorpc | ||||||
| 
 | 
 | ||||||
| from urllib.parse import urlparse | from urllib.parse import urlparse | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| class DatenpolFunctions: | class DatenpolFunctions: | ||||||
|     def __init__(self, environment, config): |     def __init__(self, environment, config): | ||||||
|         self.env = environment |         self.env = environment | ||||||
|  | @ -40,8 +41,10 @@ class DatenpolFunctions: | ||||||
|             with open(self.config.dump_file, 'rb') as dump_file: |             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) |                 self.odoo.db.restore(self.env.super_admin_pw, self.env.dbname, dump_file, True) | ||||||
|         except Exception: |         except Exception: | ||||||
|             raise Exception("Wiederherstellen der Datenbank fehlgeschlagen. Eventuell wurde './dp [env] dump' nicht ausgeführt.") |             raise Exception( | ||||||
|         print("\nACHTUNG: Nicht vergessen './dp [env] anonym' auszuführen, sodass es zu keiner Kommunikation mit dem Produktivsystem kommt") |                 "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 |         return True | ||||||
| 
 | 
 | ||||||
|     def drop_db(self): |     def drop_db(self): | ||||||
|  | @ -62,6 +65,24 @@ class DatenpolFunctions: | ||||||
| 
 | 
 | ||||||
|         res_settings = self.odoo.env['res.config.settings'] |         res_settings = self.odoo.env['res.config.settings'] | ||||||
|         vals = res_settings.default_get([]) |         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) |         vals.update(self.config.settings) | ||||||
|         wizard_id = res_settings.create(vals) |         wizard_id = res_settings.create(vals) | ||||||
|         return res_settings.execute(wizard_id) |         return res_settings.execute(wizard_id) | ||||||
|  | @ -151,12 +172,13 @@ class DatenpolFunctions: | ||||||
|         c = self.config |         c = self.config | ||||||
|         # Standard Sales Tax |         # Standard Sales Tax | ||||||
|         sales_tax_ids = self.odoo.env['account.tax'].search( |         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) |         self.odoo.env['ir.default'].set('product.template', 'taxes_id', sales_tax_ids, company_id=self.company_id.id) | ||||||
|         # Standard Purchase Tax |         # Standard Purchase Tax | ||||||
|         supplier_tax_ids = self.odoo.env['account.tax'].search( |         supplier_tax_ids = self.odoo.env['account.tax'].search( | ||||||
|                                       [('name', '=', c.default_supplier_tax)]) |             [('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) |         self.odoo.env['ir.default'].set('product.template', 'supplier_taxes_id', supplier_tax_ids, | ||||||
|  |                                         company_id=self.company_id.id) | ||||||
|         return True |         return True | ||||||
| 
 | 
 | ||||||
|     def set_incoterms(self): |     def set_incoterms(self): | ||||||
|  | @ -192,7 +214,8 @@ class DatenpolFunctions: | ||||||
|         """Module installieren""" |         """Module installieren""" | ||||||
| 
 | 
 | ||||||
|         module_to_install = [module] if module else self.config.modules |         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: |         if not len(mod_ids) == 1 and raise_exception: | ||||||
|             raise Exception('Module %s not found or is not in state "uninstalled".' % module_to_install) |             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) |         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.:')]) |         j_ids = self.odoo.env['account.journal'].search([('code', '=', 'Re.:')]) | ||||||
|         if len(j_ids) != 1: |         if len(j_ids) != 1: | ||||||
|             return False |             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 |         # Rechnungsnummer | ||||||
|         if seq_dict.get('account.invoice', False): |         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")) |         # 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( |         valid_position_ids = self.odoo.env['account.fiscal.position'].search( | ||||||
|                                            [('name', 'in', c.valid_fiscal_positions)]) |             [('name', 'in', c.valid_fiscal_positions)]) | ||||||
|         #valid_tax_ids = self.odoo.env['account.tax'].search([('parent_id', '=', False)]) |         # 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_tax_line_ids = self.odoo.env['account.fiscal.position.tax'].search( | ||||||
|  #                                             [('position_id', 'in', valid_position_ids), |         #                                             [('position_id', 'in', valid_position_ids), | ||||||
|   #                                             ('tax_dest_id', 'not in', valid_tax_ids)]) |         #                                             ('tax_dest_id', 'not in', valid_tax_ids)]) | ||||||
|   #      vals = {'tax_dest_id': False} |         #      vals = {'tax_dest_id': False} | ||||||
|    #     return self.odoo.env['account.fiscal.position.tax'].write(position_tax_line_ids, vals) |         #     return self.odoo.env['account.fiscal.position.tax'].write(position_tax_line_ids, vals) | ||||||
|         return True |         return True | ||||||
| 
 | 
 | ||||||
|     def update_module(self): |     def update_module(self): | ||||||
|  | @ -402,7 +426,7 @@ class DatenpolFunctions: | ||||||
|         """Modul Upgrade abbrechen""" |         """Modul Upgrade abbrechen""" | ||||||
|         module_name = self.config.module_name |         module_name = self.config.module_name | ||||||
|         mod_ids = self.odoo.env['ir.module.module'].search( |         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: |         if not len(mod_ids) == 1: | ||||||
|             raise Exception("Module '%s' not found or is not installed." % module_name) |             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: |         for module_name in self.config.modules: | ||||||
|             mod_ids = self.odoo.env['ir.module.module'].search( |             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: |             if not len(mod_ids) == 1: | ||||||
|                 raise Exception('Module "%s" not found or ist not installed.' % module_name) |                 raise Exception('Module "%s" not found or ist not installed.' % module_name) | ||||||
|             self.odoo.env['ir.module.module'].button_upgrade(mod_ids) |             self.odoo.env['ir.module.module'].button_upgrade(mod_ids) | ||||||
|  | @ -441,7 +465,7 @@ class DatenpolFunctions: | ||||||
|         """Name des Zentrallagers setzen""" |         """Name des Zentrallagers setzen""" | ||||||
| 
 | 
 | ||||||
|         is_installed = self.odoo.env['ir.module.module'].search( |         is_installed = self.odoo.env['ir.module.module'].search( | ||||||
|                                      [('name', '=', 'stock'), ('state', '=', 'installed')]) |             [('name', '=', 'stock'), ('state', '=', 'installed')]) | ||||||
|         if is_installed: |         if is_installed: | ||||||
|             vals = { |             vals = { | ||||||
|                 'name': self.config.warehouse_name or self.config.company_data.get('name', 'Mein Unternehmen'), |                 'name': self.config.warehouse_name or self.config.company_data.get('name', 'Mein Unternehmen'), | ||||||
|  | @ -583,7 +607,8 @@ class DatenpolFunctions: | ||||||
|                 return False |                 return False | ||||||
| 
 | 
 | ||||||
|             product_category_ids = self.odoo.env['product.category'].search([]) |             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 |         return True | ||||||
| 
 | 
 | ||||||
|     def set_default_values(self): |     def set_default_values(self): | ||||||
|  | @ -825,4 +850,3 @@ class DatenpolFunctions: | ||||||
|         if res_ids: |         if res_ids: | ||||||
|             return self.odoo.env['ir.translation'].unlink(res_ids) |             return self.odoo.env['ir.translation'].unlink(res_ids) | ||||||
|         return True |         return True | ||||||
| 
 |  | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue