Fall 5405: CR1 - Neue SST-14 / 15 + Anpassungen SST-01/03
							parent
							
								
									998b1cd90a
								
							
						
					
					
						commit
						834ee07c69
					
				|  | @ -12,9 +12,8 @@ odoo = odoorpc.ODOO(host, port=port) | ||||||
| odoo.login(db, user, pw) | odoo.login(db, user, pw) | ||||||
| 
 | 
 | ||||||
| values = { | values = { | ||||||
|     "firstname": "Max", |     "name": "Bier AG", | ||||||
|     "midname": "middle", |     "name2": "Bier2 AG", | ||||||
|     "lastname": "Musterman", |  | ||||||
|     "street": "Strasse 11", |     "street": "Strasse 11", | ||||||
|     "street2": "Zusatz 1", |     "street2": "Zusatz 1", | ||||||
|     "zip": "1145", |     "zip": "1145", | ||||||
|  | @ -25,21 +24,18 @@ values = { | ||||||
|     "mobile": "+43 677 564564", |     "mobile": "+43 677 564564", | ||||||
|     "endkunde": True, |     "endkunde": True, | ||||||
|     "portal_id": "9", |     "portal_id": "9", | ||||||
|     "company": "Bier AG", |  | ||||||
|     "info_uid": "habe keine", |     "info_uid": "habe keine", | ||||||
|     "info_kundennr": "K1234", |     "info_kundennr": "K1234", | ||||||
|     "email": "max@musterman.at", |     "email": "max@musterman.at", | ||||||
|     "line_ids": ["12345"], |     "line_ids": ["0000"], | ||||||
|     "opt_out": True, |     "opt_out": True, | ||||||
|     "lang": "de", |     "lang": "de", | ||||||
|     "collective_bill": False, |  | ||||||
|     "retailer": True, |     "retailer": True, | ||||||
|     "incoterm": "EXW", |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| res_partner_obj = odoo.env['res.partner'] | res_partner_obj = odoo.env['res.partner'] | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| result = res_partner_obj.portal_create_partner(values) | result = res_partner_obj.portal_create_company(values) | ||||||
| 
 | 
 | ||||||
| print(result) | print(result) | ||||||
|  | @ -0,0 +1,29 @@ | ||||||
|  | #!/usr/bin/env python | ||||||
|  | # -*- coding: utf-8 -*- | ||||||
|  | import odoorpc | ||||||
|  | 
 | ||||||
|  | host = 'localhost' | ||||||
|  | port = 8080 | ||||||
|  | db = 'tz-austria_1' | ||||||
|  | user = 'tz-admin' | ||||||
|  | pw = 'x' | ||||||
|  | 
 | ||||||
|  | odoo = odoorpc.ODOO(host, port=port) | ||||||
|  | odoo.login(db, user, pw) | ||||||
|  | 
 | ||||||
|  | values = { | ||||||
|  |     "firstname": "Max2", | ||||||
|  |     "lastname": "Mustemann2", | ||||||
|  |     "midname": "M.", | ||||||
|  |     "email": "max@musterman.at", | ||||||
|  |     "company_odoo_id": "6056", | ||||||
|  |     "portal_id": "5556705", | ||||||
|  |     "opt_out": True, | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | res_partner_obj = odoo.env['res.partner'] | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | result = res_partner_obj.portal_create_contact(values) | ||||||
|  | 
 | ||||||
|  | print(result) | ||||||
|  | @ -40,6 +40,7 @@ | ||||||
|     'data': [ |     'data': [ | ||||||
|         'views/commission_account.xml', |         'views/commission_account.xml', | ||||||
|         'wizards/wizard_confirm_production.xml', |         'wizards/wizard_confirm_production.xml', | ||||||
|  |         'wizards/portal_assign_company.xml', | ||||||
|         'security/security.xml', |         'security/security.xml', | ||||||
|         'data/dp_custom_data.xml', |         'data/dp_custom_data.xml', | ||||||
|         'data/glaser_company_data.xml', |         'data/glaser_company_data.xml', | ||||||
|  |  | ||||||
|  | @ -26,7 +26,7 @@ class AccountInvoiceLine(models.Model): | ||||||
|     _inherit = 'account.invoice.line' |     _inherit = 'account.invoice.line' | ||||||
| 
 | 
 | ||||||
|     intrastat_id = fields.Many2one(comodel_name='report.intrastat.code', string='Intrastat Code', |     intrastat_id = fields.Many2one(comodel_name='report.intrastat.code', string='Intrastat Code', | ||||||
|                                    compute="_compute_intrastat_id", inverse='_set_intrastat_id') |                                    compute="_compute_intrastat_id", inverse='_inverse_intrastat_id') | ||||||
|     lot_id = fields.Many2one(comodel_name='stock.production.lot', string='Lot') |     lot_id = fields.Many2one(comodel_name='stock.production.lot', string='Lot') | ||||||
|     weight = fields.Float(string='Gewicht', compute='_compute_weight') |     weight = fields.Float(string='Gewicht', compute='_compute_weight') | ||||||
| 
 | 
 | ||||||
|  | @ -54,7 +54,7 @@ class AccountInvoiceLine(models.Model): | ||||||
|         for record in self: |         for record in self: | ||||||
|             record.intrastat_id = record.lot_id.intrastat_id.id or record.product_id.intrastat_id.id |             record.intrastat_id = record.lot_id.intrastat_id.id or record.product_id.intrastat_id.id | ||||||
| 
 | 
 | ||||||
|     def _set_intrastat_id(self): |     def _inverse_intrastat_id(self): | ||||||
|         for record in self: |         for record in self: | ||||||
|             if record.lot_id: |             if record.lot_id: | ||||||
|                 record.lot_id.intrastat_id = record.intrastat_id.id |                 record.lot_id.intrastat_id = record.intrastat_id.id | ||||||
|  |  | ||||||
|  | @ -44,4 +44,4 @@ class AbstractHelper(models.AbstractModel): | ||||||
|     @api.model |     @api.model | ||||||
|     def _get_specified_fields(self): |     def _get_specified_fields(self): | ||||||
|         raise ValidationError( |         raise ValidationError( | ||||||
|             _('Method \'%s\' isn\'t Implemented in model \'%s\'' % (self._get_specified_fields.__name__, self._name))) |             _('Method \'%s\' isn\'t Implemented in model \'%s\'') % (self._get_specified_fields.__name__, self._name)) | ||||||
|  |  | ||||||
|  | @ -61,6 +61,11 @@ class ProductTemplate(models.Model): | ||||||
| 
 | 
 | ||||||
|     @api.model |     @api.model | ||||||
|     def create_product(self, vals): |     def create_product(self, vals): | ||||||
|  |         """ | ||||||
|  |         SST-10 | ||||||
|  |         :param vals: | ||||||
|  |         :return: | ||||||
|  |         """ | ||||||
|         vals = self.remove_not_specified_fields(vals) |         vals = self.remove_not_specified_fields(vals) | ||||||
|         vals = self.correct_values(vals) |         vals = self.correct_values(vals) | ||||||
|         product_template = self.with_context(active_test=False).search([('default_code', '=', vals['default_code'])]) |         product_template = self.with_context(active_test=False).search([('default_code', '=', vals['default_code'])]) | ||||||
|  | @ -78,7 +83,7 @@ class ProductTemplate(models.Model): | ||||||
|                 vals['xcat_id'] = xcat.id |                 vals['xcat_id'] = xcat.id | ||||||
|             else: |             else: | ||||||
|                 raise ValidationError( |                 raise ValidationError( | ||||||
|                     _("X-Kategorie \'%s\' kann nicht zugeordnet werden" % vals['xcat_id'])) |                     _("X-Kategorie \'%s\' kann nicht zugeordnet werden") % vals['xcat_id']) | ||||||
| 
 | 
 | ||||||
|         if vals.get('categ_id', False): |         if vals.get('categ_id', False): | ||||||
|             categ_id = self.env['product.category'].search([('code', '=', vals['categ_id'])]) |             categ_id = self.env['product.category'].search([('code', '=', vals['categ_id'])]) | ||||||
|  | @ -86,7 +91,7 @@ class ProductTemplate(models.Model): | ||||||
|                 vals['categ_id'] = categ_id.id |                 vals['categ_id'] = categ_id.id | ||||||
|             else: |             else: | ||||||
|                 raise ValidationError( |                 raise ValidationError( | ||||||
|                     _("Kategorie \'%s\' kann nicht zugeordnet werden" % vals['categ_id'])) |                     _("Kategorie \'%s\' kann nicht zugeordnet werden") % vals['categ_id']) | ||||||
| 
 | 
 | ||||||
|         if vals.get('material_type_id', False): |         if vals.get('material_type_id', False): | ||||||
|             material_type = self.env['material.type'].search([('name', '=', vals['material_type_id'])]) |             material_type = self.env['material.type'].search([('name', '=', vals['material_type_id'])]) | ||||||
|  | @ -94,7 +99,7 @@ class ProductTemplate(models.Model): | ||||||
|                 vals['material_type_id'] = material_type.id |                 vals['material_type_id'] = material_type.id | ||||||
|             else: |             else: | ||||||
|                 raise ValidationError( |                 raise ValidationError( | ||||||
|                     _("Materialtyp \'%s\' kann nicht zugeordnet werden" % vals['material_type_id'])) |                     _("Materialtyp \'%s\' kann nicht zugeordnet werden") % vals['material_type_id']) | ||||||
| 
 | 
 | ||||||
|         if vals.get('intrastat_id', False): |         if vals.get('intrastat_id', False): | ||||||
|             intrastat = self.env['report.intrastat.code'].search([('name', '=', vals['intrastat_id'])]) |             intrastat = self.env['report.intrastat.code'].search([('name', '=', vals['intrastat_id'])]) | ||||||
|  | @ -102,7 +107,7 @@ class ProductTemplate(models.Model): | ||||||
|                 vals['intrastat_id'] = intrastat.id |                 vals['intrastat_id'] = intrastat.id | ||||||
|             else: |             else: | ||||||
|                 raise ValidationError( |                 raise ValidationError( | ||||||
|                     _("Intrastat-Code \'%s\' kann nicht zugeordnet werden" % vals['intrastat_id'])) |                     _("Intrastat-Code \'%s\' kann nicht zugeordnet werden") % vals['intrastat_id']) | ||||||
| 
 | 
 | ||||||
|         if vals.get('assembly_line_ids', False): |         if vals.get('assembly_line_ids', False): | ||||||
|             assembly_line_ids = [] |             assembly_line_ids = [] | ||||||
|  | @ -112,7 +117,7 @@ class ProductTemplate(models.Model): | ||||||
|                     assembly_line_ids.append(assembly_line.id) |                     assembly_line_ids.append(assembly_line.id) | ||||||
|                 else: |                 else: | ||||||
|                     raise ValidationError( |                     raise ValidationError( | ||||||
|                         _("Produktionslinie \'%s\' kann nicht zugeordnet werden" % assembly_line_code)) |                         _("Produktionslinie \'%s\' kann nicht zugeordnet werden") % assembly_line_code) | ||||||
|             vals['assembly_line_ids'] = [(6, 0, assembly_line_ids)] |             vals['assembly_line_ids'] = [(6, 0, assembly_line_ids)] | ||||||
| 
 | 
 | ||||||
|         return vals |         return vals | ||||||
|  |  | ||||||
|  | @ -19,14 +19,14 @@ | ||||||
| # | # | ||||||
| ############################################################################## | ############################################################################## | ||||||
| import json | import json | ||||||
|  | 
 | ||||||
| import requests | import requests | ||||||
|  | from odoo.addons.component.core import Component | ||||||
|  | from odoo.addons.queue_job.job import job | ||||||
| 
 | 
 | ||||||
| from odoo import tools, api, fields, models, _ | from odoo import tools, api, fields, models, _ | ||||||
| from odoo.exceptions import ValidationError | from odoo.exceptions import ValidationError | ||||||
| 
 | 
 | ||||||
| from odoo.addons.queue_job.job import job |  | ||||||
| from odoo.addons.component.core import Component |  | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| class PartnerEventListener(Component): | class PartnerEventListener(Component): | ||||||
|     _name = 'res.partner.listener' |     _name = 'res.partner.listener' | ||||||
|  | @ -55,10 +55,13 @@ class Partner(models.Model): | ||||||
|     def _default_country_id(self): |     def _default_country_id(self): | ||||||
|         return self.env.ref('base.at') |         return self.env.ref('base.at') | ||||||
| 
 | 
 | ||||||
|     company = fields.Char(string='Unternehmen') |     name2 = fields.Char('Unternehmensname 2') | ||||||
|     info_kundennr = fields.Char(string='Info-Kundennr.') |     info_kundennr = fields.Char(string='Info-Kundennr.') | ||||||
|     info_uid = fields.Char(string='Info-UID') |     info_uid = fields.Char(string='Info-UID') | ||||||
|     endkunde = fields.Boolean(string='Endkunde', help='Beschreibt, ob es ein Endkunde ist') |     endkunde = fields.Boolean(string='Endkunde', help='Beschreibt, ob es ein Endkunde ist') | ||||||
|  |     portal_pending = fields.Boolean('Erwarte Zuordnung', help='Wird vom Portal bei neuen Unternehmen gesetzt. ' | ||||||
|  |                                                               'Sobald das Unternehmen manuell zugewiesen wurde, ' | ||||||
|  |                                                               'wird das Flag wieder entfernt') | ||||||
|     line_ids = fields.Many2many(comodel_name='res.line', string='Produktionslinien') |     line_ids = fields.Many2many(comodel_name='res.line', string='Produktionslinien') | ||||||
|     portal_id = fields.Char(string='Portal-ID') |     portal_id = fields.Char(string='Portal-ID') | ||||||
|     partner_sector_id = fields.Many2one(comodel_name='res.partner.sector', string='Branche') |     partner_sector_id = fields.Many2one(comodel_name='res.partner.sector', string='Branche') | ||||||
|  | @ -74,35 +77,62 @@ class Partner(models.Model): | ||||||
|         ('portal_id_uniq', 'unique(portal_id)', 'Die Portal-ID muss eindeutig sein') |         ('portal_id_uniq', 'unique(portal_id)', 'Die Portal-ID muss eindeutig sein') | ||||||
|     ] |     ] | ||||||
| 
 | 
 | ||||||
|     @api.one |     @api.multi | ||||||
|     @api.constrains('is_company', 'vat') |     @api.constrains('is_company', 'vat') | ||||||
|     def _check_unique_vat(self): |     def _check_unique_vat(self): | ||||||
|         if not self.vat or (not self.is_company and self.parent_id): |         for record in self: | ||||||
|             return |             if not record.vat or (not record.is_company and record.parent_id): | ||||||
|         partners = self.search([('is_company', '=', True), |                 continue | ||||||
|                                 ('vat', '=', self.vat), |             partners = self.search([('is_company', '=', True), | ||||||
|                                 ('id', '!=', self.id)]) |                                     ('vat', '=', self.vat), | ||||||
|         if partners: |                                     ('id', '!=', self.id)]) | ||||||
|             raise ValidationError(_("UID-Exists: Es sind bereits folgende Unternehmen mit der selben USt. ID vorhanden: %s") % [p.name for p in partners]) |             if partners: | ||||||
|  |                 raise ValidationError(_("UID-Exists: Es sind bereits folgende Unternehmen mit der selben USt. ID " | ||||||
|  |                                         "vorhanden: %s") % [p.name for p in partners]) | ||||||
| 
 | 
 | ||||||
|     @api.model |     @api.model | ||||||
|     def portal_create_partner(self, vals): |     def portal_create_company(self, vals): | ||||||
|  |         """ | ||||||
|  |         SST-01 | ||||||
|  |         :param vals: | ||||||
|  |         :return: | ||||||
|  |         """ | ||||||
|         vals = self.with_context(sst_1=True).remove_not_specified_fields(vals) |         vals = self.with_context(sst_1=True).remove_not_specified_fields(vals) | ||||||
|         vals = self.correct_values(vals) |         vals = self.correct_values(vals) | ||||||
|         if not vals.get('active', False): |         if not vals.get('active', False): | ||||||
|             vals['active'] = False |             vals['active'] = False | ||||||
|  |         vals['is_company'] = True | ||||||
|  |         vals['portal_pending'] = True | ||||||
|         self.create(vals) |         self.create(vals) | ||||||
|         return True |         return True | ||||||
| 
 | 
 | ||||||
|  |     @api.model | ||||||
|  |     def portal_create_contact(self, vals): | ||||||
|  |         """ | ||||||
|  |         SST-14 | ||||||
|  |         :param vals: | ||||||
|  |         :return: | ||||||
|  |         """ | ||||||
|  |         vals = self.with_context(sst_14=True).remove_not_specified_fields(vals) | ||||||
|  |         vals = self.correct_values(vals) | ||||||
|  |         if not vals.get('active', False): | ||||||
|  |             vals['active'] = False | ||||||
|  |         return self.create(vals).id | ||||||
|  | 
 | ||||||
|     @api.model |     @api.model | ||||||
|     def pg_create_company(self, vals): |     def pg_create_company(self, vals): | ||||||
|  |         """ | ||||||
|  |         SST-11 | ||||||
|  |         :param vals: | ||||||
|  |         :return: | ||||||
|  |         """ | ||||||
|         vals = self.with_context(sst_11=True).remove_not_specified_fields(vals) |         vals = self.with_context(sst_11=True).remove_not_specified_fields(vals) | ||||||
|         vals = self.correct_values(vals) |         vals = self.correct_values(vals) | ||||||
|         partner = self.with_context(active_test=False).search([('ref', '=', vals['ref'])]) |         partner = self.with_context(active_test=False).search([('ref', '=', vals['ref'])]) | ||||||
|         if partner: |         if partner: | ||||||
|             if not partner.is_company: |             if not partner.is_company: | ||||||
|                 raise ValidationError( |                 raise ValidationError( | ||||||
|                     _("Der Partner mit der Internen Referenz '%s' ist kein Unternehmen" % vals['ref'])) |                     _("Der Partner mit der Internen Referenz '%s' ist kein Unternehmen") % vals['ref']) | ||||||
|             partner.write(vals) |             partner.write(vals) | ||||||
|         else: |         else: | ||||||
|             if not vals.get('is_company', False): |             if not vals.get('is_company', False): | ||||||
|  | @ -120,7 +150,7 @@ class Partner(models.Model): | ||||||
|                 vals['country_id'] = country.id |                 vals['country_id'] = country.id | ||||||
|             else: |             else: | ||||||
|                 raise ValidationError( |                 raise ValidationError( | ||||||
|                     _("Das Land mit dem ISO-Code \'%s\' kann nicht zugeordnet werden" % vals['country_id'])) |                     _("Das Land mit dem ISO-Code \'%s\' kann nicht zugeordnet werden") % vals['country_id']) | ||||||
| 
 | 
 | ||||||
|         if vals.get('line_ids', False): |         if vals.get('line_ids', False): | ||||||
|             line_ids = self.env['res.line'].search([('name', 'in', vals['line_ids'])]) |             line_ids = self.env['res.line'].search([('name', 'in', vals['line_ids'])]) | ||||||
|  | @ -128,7 +158,7 @@ class Partner(models.Model): | ||||||
|                 vals['line_ids'] = [(6, 0, line_ids.ids)] |                 vals['line_ids'] = [(6, 0, line_ids.ids)] | ||||||
|             else: |             else: | ||||||
|                 raise ValidationError( |                 raise ValidationError( | ||||||
|                     _("Die Produktionslinie mit dem Code \'%s\' kann nicht zugeordnet werden" % vals['line_ids'])) |                     _("Die Produktionslinie mit dem Code \'%s\' kann nicht zugeordnet werden") % vals['line_ids']) | ||||||
| 
 | 
 | ||||||
|         if vals.get('lang', False): |         if vals.get('lang', False): | ||||||
|             temp = vals['lang'] |             temp = vals['lang'] | ||||||
|  | @ -138,7 +168,7 @@ class Partner(models.Model): | ||||||
|                     vals['lang'] = selection[0] |                     vals['lang'] = selection[0] | ||||||
|                     break |                     break | ||||||
|             if not vals['lang']: |             if not vals['lang']: | ||||||
|                 raise ValidationError(_("Die Sprache mit dem Code \'%s\' kann nicht zugeordnet werden" % temp)) |                 raise ValidationError(_("Die Sprache mit dem Code \'%s\' kann nicht zugeordnet werden") % temp) | ||||||
| 
 | 
 | ||||||
|         if vals.get('partner_sector_id', False): |         if vals.get('partner_sector_id', False): | ||||||
|             branche = self.env['res.partner.sector'].search( |             branche = self.env['res.partner.sector'].search( | ||||||
|  | @ -146,7 +176,7 @@ class Partner(models.Model): | ||||||
|             if branche: |             if branche: | ||||||
|                 vals['partner_sector_id'] = branche.id |                 vals['partner_sector_id'] = branche.id | ||||||
|             else: |             else: | ||||||
|                 raise ValidationError(_("Die Branche \'%s\' kann nicht zugeordnet werden" % vals['partner_sector_id'])) |                 raise ValidationError(_("Die Branche \'%s\' kann nicht zugeordnet werden") % vals['partner_sector_id']) | ||||||
| 
 | 
 | ||||||
|         if vals.get('property_payment_term_id', False): |         if vals.get('property_payment_term_id', False): | ||||||
|             payment_term = self.env['account.payment.term'].search( |             payment_term = self.env['account.payment.term'].search( | ||||||
|  | @ -154,8 +184,9 @@ class Partner(models.Model): | ||||||
|             if payment_term: |             if payment_term: | ||||||
|                 vals['property_payment_term_id'] = payment_term.id |                 vals['property_payment_term_id'] = payment_term.id | ||||||
|             else: |             else: | ||||||
|                 raise ValidationError(_("Die Zahlungsbedingung mit dem Code \'%s\' kann nicht zugeordnet werden" % vals[ |                 raise ValidationError( | ||||||
|                     'property_payment_term_id'])) |                     _("Die Zahlungsbedingung mit dem Code \'%s\' kann nicht zugeordnet werden") % vals[ | ||||||
|  |                         'property_payment_term_id']) | ||||||
| 
 | 
 | ||||||
|         if vals.get('property_product_pricelist', False): |         if vals.get('property_product_pricelist', False): | ||||||
|             product_pricelist = self.env['product.pricelist'].search( |             product_pricelist = self.env['product.pricelist'].search( | ||||||
|  | @ -163,8 +194,8 @@ class Partner(models.Model): | ||||||
|             if product_pricelist: |             if product_pricelist: | ||||||
|                 vals['property_product_pricelist'] = product_pricelist[0].id |                 vals['property_product_pricelist'] = product_pricelist[0].id | ||||||
|             else: |             else: | ||||||
|                 raise ValidationError(_("Die Preisliste mit der Währung \'%s\' kann nicht zugeordnet werden" % vals[ |                 raise ValidationError(_("Die Preisliste mit der Währung \'%s\' kann nicht zugeordnet werden") % vals[ | ||||||
|                     'property_product_pricelist'])) |                     'property_product_pricelist']) | ||||||
| 
 | 
 | ||||||
|         if vals.get('retail_partner_id', False): |         if vals.get('retail_partner_id', False): | ||||||
|             retail_partner = self.env['res.partner'].search( |             retail_partner = self.env['res.partner'].search( | ||||||
|  | @ -172,8 +203,9 @@ class Partner(models.Model): | ||||||
|             if retail_partner: |             if retail_partner: | ||||||
|                 vals['retail_partner_id'] = retail_partner.id |                 vals['retail_partner_id'] = retail_partner.id | ||||||
|             else: |             else: | ||||||
|                 raise ValidationError(_("Der Händler mit der Internen Referenz \'%s\' kann nicht zugeordnet werden" % vals[ |                 raise ValidationError( | ||||||
|                     'retail_partner_id'])) |                     _("Der Händler mit der Internen Referenz \'%s\' kann nicht zugeordnet werden") % vals[ | ||||||
|  |                         'retail_partner_id']) | ||||||
| 
 | 
 | ||||||
|         if vals.get('incoterm', False): |         if vals.get('incoterm', False): | ||||||
|             incoterm = self.env['stock.incoterms'].search( |             incoterm = self.env['stock.incoterms'].search( | ||||||
|  | @ -182,8 +214,24 @@ class Partner(models.Model): | ||||||
|                 vals['sale_incoterm_id'] = incoterm.id |                 vals['sale_incoterm_id'] = incoterm.id | ||||||
|                 del vals['incoterm'] |                 del vals['incoterm'] | ||||||
|             else: |             else: | ||||||
|                 raise ValidationError(_("Die Lieferbedingung mit dem Code \'%s\' kann nicht zugeordnet werden" % vals[ |                 raise ValidationError( | ||||||
|                     'incoterm'])) |                     _("Die Lieferbedingung mit dem Code \'%s\' kann nicht zugeordnet werden") % vals['incoterm']) | ||||||
|  | 
 | ||||||
|  |         if vals.get('company_odoo_id', False): | ||||||
|  |             parent_id = self.env['res.partner'].search([('id', '=', vals['company_odoo_id'])]) | ||||||
|  |             if parent_id: | ||||||
|  |                 vals['parent_id'] = parent_id.id | ||||||
|  |                 vals['street'] = parent_id.street | ||||||
|  |                 vals['street2'] = parent_id.street2 | ||||||
|  |                 vals['city'] = parent_id.city | ||||||
|  |                 vals['zip'] = parent_id.zip | ||||||
|  |                 vals['country_id'] = parent_id.country_id.id | ||||||
|  |                 vals['supplier'] = parent_id.supplier | ||||||
|  |                 vals['customer'] = parent_id.customer | ||||||
|  |                 vals['lang'] = parent_id.lang | ||||||
|  |                 del vals['company_odoo_id'] | ||||||
|  |             else: | ||||||
|  |                 raise ValidationError(_("Unternehmen mit Odoo-ID \'%s\' existiert nicht") % vals['company_odoo_id']) | ||||||
| 
 | 
 | ||||||
|         return vals |         return vals | ||||||
| 
 | 
 | ||||||
|  | @ -192,13 +240,14 @@ class Partner(models.Model): | ||||||
|         common_list = ['street', 'street2', 'zip', 'city', 'country_id', 'fax', 'phone', 'mobile', |         common_list = ['street', 'street2', 'zip', 'city', 'country_id', 'fax', 'phone', 'mobile', | ||||||
|                        'endkunde', 'line_ids', 'lang', 'portal_id', 'email', 'opt_out'] |                        'endkunde', 'line_ids', 'lang', 'portal_id', 'email', 'opt_out'] | ||||||
|         if self.env.context.get('sst_1', False): |         if self.env.context.get('sst_1', False): | ||||||
|             common_list.extend(['firstname', 'lastname', 'midname', 'company', 'info_kundennr', |             common_list.extend(['name', 'name2', 'info_kundennr', 'info_uid', 'retailer']) | ||||||
|                                 'info_uid', 'collective_bill', 'retailer', 'incoterm']) |  | ||||||
|             return common_list |             return common_list | ||||||
|         elif self.env.context.get('sst_11', False): |         elif self.env.context.get('sst_11', False): | ||||||
|             common_list.extend(['name', 'ref', 'partner_sector_id', 'comment', 'vat', 'property_payment_term_id', |             common_list.extend(['name', 'ref', 'partner_sector_id', 'comment', 'vat', 'property_payment_term_id', | ||||||
|                                 'property_pricelist_id', 'date_vat_check', 'active', 'property_product_pricelist', |                                 'property_pricelist_id', 'date_vat_check', 'active', 'property_product_pricelist', | ||||||
|                                 'retail_partner_id', 'retailer', 'info_uid']) |                                 'retail_partner_id', 'retailer', 'info_uid']) | ||||||
|  |         elif self.env.context.get('sst_14', False): | ||||||
|  |             common_list.extend(['firstname', 'lastname', 'midname', 'company_odoo_id', 'portal_id']) | ||||||
|             return common_list |             return common_list | ||||||
|         else: |         else: | ||||||
|             return super(Partner, self)._get_specified_fields() |             return super(Partner, self)._get_specified_fields() | ||||||
|  | @ -215,7 +264,7 @@ class Partner(models.Model): | ||||||
|     @job |     @job | ||||||
|     def job_export_portal_price(self, partner_id): |     def job_export_portal_price(self, partner_id): | ||||||
|         if not partner_id.portal_id: |         if not partner_id.portal_id: | ||||||
|             raise ValidationError(_("Der Partner mit der ID %s hat keine Portal-ID" % partner_id.id)) |             raise ValidationError(_("Der Partner mit der ID %s hat keine Portal-ID") % partner_id.id) | ||||||
|         pricelist = partner_id.property_product_pricelist |         pricelist = partner_id.property_product_pricelist | ||||||
|         data = [] |         data = [] | ||||||
|         for item in pricelist.item_ids: |         for item in pricelist.item_ids: | ||||||
|  |  | ||||||
|  | @ -94,6 +94,13 @@ class SaleOrder(models.Model): | ||||||
| 
 | 
 | ||||||
|     @api.model |     @api.model | ||||||
|     def pg_get_orders(self, line, state, limit): |     def pg_get_orders(self, line, state, limit): | ||||||
|  |         """ | ||||||
|  |         SST-4 | ||||||
|  |         :param line: | ||||||
|  |         :param state: | ||||||
|  |         :param limit: | ||||||
|  |         :return: | ||||||
|  |         """ | ||||||
|         line_id = self.env['res.line'].search([('name', '=', line)]) |         line_id = self.env['res.line'].search([('name', '=', line)]) | ||||||
|         orders = self.search([('line_id', '=', line_id.id), ('assembly_state', '=', state)], order='id ASC', |         orders = self.search([('line_id', '=', line_id.id), ('assembly_state', '=', state)], order='id ASC', | ||||||
|                              limit=limit) |                              limit=limit) | ||||||
|  | @ -127,13 +134,22 @@ class SaleOrder(models.Model): | ||||||
| 
 | 
 | ||||||
|     @api.model |     @api.model | ||||||
|     def pg_create_quotation(self, vals): |     def pg_create_quotation(self, vals): | ||||||
|  |         """ | ||||||
|  |         SST-3 | ||||||
|  |         :param vals: | ||||||
|  |         :return: | ||||||
|  |         """ | ||||||
|         if not vals.get('portal_id', False): |         if not vals.get('portal_id', False): | ||||||
|             raise ValidationError( |             raise ValidationError( | ||||||
|                 _("Der Kunde mit der Portal-ID \'%s\' kann nicht zugeordnet werden" % vals['portal_id'])) |                 _("Der Kunde mit der Portal-ID \'%s\' kann nicht zugeordnet werden") % vals['portal_id']) | ||||||
|         partner = self.env['res.partner'].search([('portal_id', '=', vals['portal_id'])]) |         partner = self.env['res.partner'].search([('portal_id', '=', vals['portal_id'])]) | ||||||
|  |         if not partner.parent_id: | ||||||
|  |             raise ValidationError( | ||||||
|  |                 _('Zu dem Kontakt mit der portal-ID %s existiert kein Unternehmen') % vals['portal_id']) | ||||||
|  |         vals['partner_id'] = partner.parent_id.id | ||||||
|         if not partner: |         if not partner: | ||||||
|             raise ValidationError( |             raise ValidationError( | ||||||
|                 _("Der Kunde mit der Portal-ID \'%s\' kann nicht zugeordnet werden" % vals['portal_id'])) |                 _("Der Kunde mit der Portal-ID \'%s\' kann nicht zugeordnet werden") % vals['portal_id']) | ||||||
|         delivery_partner = self.env['res.partner'] |         delivery_partner = self.env['res.partner'] | ||||||
|         delivery_vals = {} |         delivery_vals = {} | ||||||
|         if vals.get('portal_delivery_id', False): |         if vals.get('portal_delivery_id', False): | ||||||
|  | @ -236,7 +252,7 @@ class SaleOrder(models.Model): | ||||||
|                 vals['line_id'] = line_id.id |                 vals['line_id'] = line_id.id | ||||||
|             else: |             else: | ||||||
|                 raise ValidationError( |                 raise ValidationError( | ||||||
|                     _("Produktionslinie \'%s\' kann nicht zugeordnet werden" % vals['line_id'])) |                     _("Produktionslinie \'%s\' kann nicht zugeordnet werden") % vals['line_id']) | ||||||
|         return vals |         return vals | ||||||
| 
 | 
 | ||||||
|     @api.model |     @api.model | ||||||
|  | @ -351,7 +367,7 @@ class SaleOrderLine(models.Model): | ||||||
|                 vals['product_id'] = product_id.id |                 vals['product_id'] = product_id.id | ||||||
|             else: |             else: | ||||||
|                 raise ValidationError( |                 raise ValidationError( | ||||||
|                     _("Produkt \'%s\' kann nicht zugeordnet werden" % vals['product_id'])) |                     _("Produkt \'%s\' kann nicht zugeordnet werden") % vals['product_id']) | ||||||
|         return vals |         return vals | ||||||
| 
 | 
 | ||||||
|     @api.multi |     @api.multi | ||||||
|  |  | ||||||
|  | @ -1,35 +1,27 @@ | ||||||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||||
| <odoo> | <odoo> | ||||||
| 
 | 
 | ||||||
|     <record id="view_partner_address_form" model="ir.ui.view"> |  | ||||||
|         <field name="name">view_partner_address_form</field> |  | ||||||
|         <field name="model">res.partner</field> |  | ||||||
|         <field name="inherit_id" ref="base.view_partner_address_form"/> |  | ||||||
|         <field name="arch" type="xml"> |  | ||||||
|             <field name="street" position="before"> |  | ||||||
|                 <field name="company"/> |  | ||||||
|             </field> |  | ||||||
|         </field> |  | ||||||
|     </record> |  | ||||||
| 
 |  | ||||||
|     <record id="view_partner_form" model="ir.ui.view"> |     <record id="view_partner_form" model="ir.ui.view"> | ||||||
|         <field name="name">view_partner_form</field> |         <field name="name">view_partner_form</field> | ||||||
|         <field name="model">res.partner</field> |         <field name="model">res.partner</field> | ||||||
|         <field name="inherit_id" ref="base.view_partner_form"/> |         <field name="inherit_id" ref="base.view_partner_form"/> | ||||||
|         <field name="arch" type="xml"> |         <field name="arch" type="xml"> | ||||||
|             <xpath expr="/form/sheet/group/group[1]/label" position="before"> |             <xpath expr="//sheet" position="before"> | ||||||
|                 <field name="company"/> |                 <header> | ||||||
|  |                     <button name="%(portal_assign_company_action)d" string="Unternehmen zuordnen" type="action" | ||||||
|  |                             class="btn-danger" attrs="{'invisible':[('portal_pending','=',False)]}"/> | ||||||
|  |                 </header> | ||||||
|  |             </xpath> | ||||||
|  |             <xpath expr="//h1" position="after"> | ||||||
|  |                 <h3> | ||||||
|  |                     <field name="name2" attrs="{'invisible': [('is_company', '=', False)]}"/> | ||||||
|  |                 </h3> | ||||||
|             </xpath> |             </xpath> | ||||||
| 
 | 
 | ||||||
|             <field name="opt_out" position="attributes"> |             <field name="opt_out" position="attributes"> | ||||||
|                 <attribute name="groups"/> |                 <attribute name="groups"/> | ||||||
|             </field> |             </field> | ||||||
| 
 | 
 | ||||||
|             <xpath expr="//field[@name='child_ids']/form/sheet/group/group[1]/label" |  | ||||||
|                    position="before"> |  | ||||||
|                 <field name="company"/> |  | ||||||
|             </xpath> |  | ||||||
| 
 |  | ||||||
|             <xpath expr="//page[@name='internal_notes']/field[@name='comment']" position="replace"> |             <xpath expr="//page[@name='internal_notes']/field[@name='comment']" position="replace"> | ||||||
|                 <group name="description"> |                 <group name="description"> | ||||||
|                     <group string="Interner Hinweis"> |                     <group string="Interner Hinweis"> | ||||||
|  | @ -52,6 +44,7 @@ | ||||||
| 
 | 
 | ||||||
|             <xpath expr="//field[@name='category_id']" position="after"> |             <xpath expr="//field[@name='category_id']" position="after"> | ||||||
|                 <field name="endkunde"/> |                 <field name="endkunde"/> | ||||||
|  |                 <field name="portal_pending" attrs="{'invisible': [('portal_pending', '=', False)]}"/> | ||||||
|                 <field name="partner_sector_id"/> |                 <field name="partner_sector_id"/> | ||||||
|             </xpath> |             </xpath> | ||||||
| 
 | 
 | ||||||
|  | @ -68,7 +61,7 @@ | ||||||
|         <field name="name">Neue Portalkunden</field> |         <field name="name">Neue Portalkunden</field> | ||||||
|         <field name="type">ir.actions.act_window</field> |         <field name="type">ir.actions.act_window</field> | ||||||
|         <field name="res_model">res.partner</field> |         <field name="res_model">res.partner</field> | ||||||
|         <field name="domain">[('active','=',False), ('portal_id','!=',False), ('is_company','=',False)]</field> |         <field name="domain">[('active','=',False), ('portal_pending','=',True)]</field> | ||||||
|         <field name="target">current</field> |         <field name="target">current</field> | ||||||
|         <field name="view_type">form</field> |         <field name="view_type">form</field> | ||||||
|         <field name="view_mode">tree,form</field> |         <field name="view_mode">tree,form</field> | ||||||
|  |  | ||||||
|  | @ -1 +1,2 @@ | ||||||
| from . import wizard_confirm_production | from . import wizard_confirm_production | ||||||
|  | from . import portal_assign_company | ||||||
|  |  | ||||||
|  | @ -0,0 +1,71 @@ | ||||||
|  | # Copyright 2018-Today datenpol gmbh (<http://www.datenpol.at>) | ||||||
|  | # License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses). | ||||||
|  | import json | ||||||
|  | 
 | ||||||
|  | import requests | ||||||
|  | 
 | ||||||
|  | from odoo import tools, api, fields, models, _ | ||||||
|  | from odoo.exceptions import ValidationError | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class PortalAssignCompany(models.TransientModel): | ||||||
|  |     _name = 'portal.assign_company' | ||||||
|  |     _description = 'Unternehmen zuordnen' | ||||||
|  | 
 | ||||||
|  |     main_partner_id = fields.Many2one('res.partner', 'Zugewiesenes Unternehmen', domain=[('is_company', '=', True)]) | ||||||
|  | 
 | ||||||
|  |     @api.onchange('main_partner_id') | ||||||
|  |     def _onchange_main_partner_id(self): | ||||||
|  |         for record in self: | ||||||
|  |             if record.main_partner_id and record.main_partner_id.portal_id: | ||||||
|  |                 return { | ||||||
|  |                     'warning': { | ||||||
|  |                         'title': _('Warning!'), | ||||||
|  |                         'message': _('Achtung: Das ausgewählte Unternehmen ist bereits mit dem Portal verknüpft. ' | ||||||
|  |                                      'Wenn Sie das Unternehmen zuweisen, dann könnte es zu Problemen im Portal kommen'), | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |     def send_to_portal(self, portal_id, odoo_id): | ||||||
|  |         """ | ||||||
|  |         SST-15 | ||||||
|  |         :param portal_id: | ||||||
|  |         :param odoo_id: | ||||||
|  |         :return: | ||||||
|  |         """ | ||||||
|  |         self.ensure_one() | ||||||
|  |         portal_url = tools.config.get('portal_url') | ||||||
|  |         application_id = tools.config.get('portal_secret') | ||||||
|  |         data = { | ||||||
|  |             'portal_id': int(portal_id), | ||||||
|  |             'company_odoo_id': odoo_id | ||||||
|  |         } | ||||||
|  |         response = requests.post(portal_url + '/api/v1/set-odoo-id/?secret=' + application_id, | ||||||
|  |                                  data=json.dumps(data)) | ||||||
|  |         if response.status_code != 200: | ||||||
|  |             raise ValidationError(_('Die Odoo id konnte für den partner nicht gesetzt werden.' | ||||||
|  |                                     'Status Code: %s, Reason: %s') % (response.status_code, response.reason)) | ||||||
|  | 
 | ||||||
|  |     def button_activate(self): | ||||||
|  |         self.ensure_one() | ||||||
|  |         partner = self.env['res.partner'].browse(self.env.context.get('active_ids', [])) | ||||||
|  |         if not partner: | ||||||
|  |             raise ValidationError(_('Der Partner konnte nicht gefuden werden.')) | ||||||
|  | 
 | ||||||
|  |         partner.write({'portal_pending': False, 'active': True}) | ||||||
|  | 
 | ||||||
|  |         return self.send_to_portal(partner.portal_id, partner.id) | ||||||
|  | 
 | ||||||
|  |     def button_assign(self): | ||||||
|  |         self.ensure_one() | ||||||
|  |         if self.main_partner_id: | ||||||
|  |             partner = self.env['res.partner'].browse(self.env.context.get('active_ids', [])) | ||||||
|  |             if not partner: | ||||||
|  |                 raise ValidationError(_('Der Partner konnte nicht gefuden werden.')) | ||||||
|  |             if not self.main_partner_id.portal_id: | ||||||
|  |                 self.main_partner_id.portal_id = partner.portal_id | ||||||
|  |             self.send_to_portal(self.main_partner_id.portal_id, self.main_partner_id.id) | ||||||
|  |             partner.unlink() | ||||||
|  | 
 | ||||||
|  |             return self.env.ref('base.action_partner_form').read()[0] | ||||||
|  |         return {'type': 'ir.actions.act_window_close'} | ||||||
|  | @ -0,0 +1,41 @@ | ||||||
|  | <?xml version="1.0" encoding="utf-8"?> | ||||||
|  | <!-- Copyright 2018-Today datenpol gmbh(<http://www.datenpol.at>) | ||||||
|  |      License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses). --> | ||||||
|  | 
 | ||||||
|  | <odoo> | ||||||
|  | 
 | ||||||
|  |     <record id="portal_assign_company_form_view" model="ir.ui.view"> | ||||||
|  |         <field name="name">portal_assign_company_form_view</field> | ||||||
|  |         <field name="model">portal.assign_company</field> | ||||||
|  |         <field name="arch" type="xml"> | ||||||
|  |             <form string="Wizard Confirm Production"> | ||||||
|  |                 <group> | ||||||
|  |                     <p>Sobald das Unternehmen aus dem Portal zugewiesen bzw. aktiviert wurde, | ||||||
|  |                         wird die Kunde-Preisliste an das Portal übergeben und Aufträge aus dem Portal | ||||||
|  |                         können durchgeführt werden. | ||||||
|  |                     </p> | ||||||
|  |                 </group> | ||||||
|  |                 <group> | ||||||
|  |                     <field name="main_partner_id"/> | ||||||
|  |                 </group> | ||||||
|  |                 <footer> | ||||||
|  |                     <button name="button_activate" string="Als Neu Aktivieren" class="btn-danger" type="object" | ||||||
|  |                             attrs="{'invisible': [('main_partner_id', '!=', False)]}"/> | ||||||
|  |                     <button name="button_assign" string="Unternehmen zuweisen" class="btn-danger" type="object" | ||||||
|  |                             attrs="{'invisible': [('main_partner_id', '=', False)]}"/> | ||||||
|  |                     <button string="Abbrechen" class="btn-default" special="cancel"/> | ||||||
|  |                 </footer> | ||||||
|  |             </form> | ||||||
|  |         </field> | ||||||
|  |     </record> | ||||||
|  | 
 | ||||||
|  |     <record id="portal_assign_company_action" model="ir.actions.act_window"> | ||||||
|  |         <field name="name">Unternehmen zuordnen</field> | ||||||
|  |         <field name="res_model">portal.assign_company</field> | ||||||
|  |         <field name="view_mode">form</field> | ||||||
|  |         <field name="context">{}</field> | ||||||
|  |         <field name="target">new</field> | ||||||
|  |     </record> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | </odoo> | ||||||
|  | @ -21,7 +21,7 @@ class WizardConfirmProduction(models.TransientModel): | ||||||
|                     if so.assembly_state == 'created' and so.state == 'sale': |                     if so.assembly_state == 'created' and so.state == 'sale': | ||||||
|                         so.assembly_state = 'approved' |                         so.assembly_state = 'approved' | ||||||
|                     else: |                     else: | ||||||
|                         raise ValidationError(_('Auftrag %s: Bitte prüfen Sie den PG-Status und/oder Auftragsstatus.' % so.name)) |                         raise ValidationError(_('Auftrag %s: Bitte prüfen Sie den PG-Status und/oder Auftragsstatus.') % so.name) | ||||||
|             action = self.env.ref('sale.action_orders').read()[0] |             action = self.env.ref('sale.action_orders').read()[0] | ||||||
|             action['domain'] = [('id', 'in', active_ids)] |             action['domain'] = [('id', 'in', active_ids)] | ||||||
|             return action |             return action | ||||||
|  |  | ||||||
|  | @ -44,4 +44,3 @@ class AccountInvoiceWithIntrastat(models.AbstractModel): | ||||||
|             'field_set_in_lines': self._field_set_in_lines, |             'field_set_in_lines': self._field_set_in_lines, | ||||||
|             'formatLang': self._formatLang, |             'formatLang': self._formatLang, | ||||||
|         } |         } | ||||||
| 
 |  | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue