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_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, | ||||
|  |  | |||
|  | @ -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) | ||||
|  | @ -156,7 +177,8 @@ class DatenpolFunctions: | |||
|         # 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) | ||||
|         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): | ||||
|  | @ -349,9 +373,9 @@ 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)]) | ||||
|         # 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), | ||||
|         #                                             ('tax_dest_id', 'not in', valid_tax_ids)]) | ||||
|         #      vals = {'tax_dest_id': False} | ||||
|  | @ -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 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue