diff --git a/dev/odoo-server-dev-aa.conf b/dev/odoo-server-dev-aa.conf index ad8880a1..c648544e 100644 --- a/dev/odoo-server-dev-aa.conf +++ b/dev/odoo-server-dev-aa.conf @@ -19,8 +19,8 @@ show_debug = 1 workers = 0 server_wide_modules = web,base_sparse_field,queue_job -portal_url = https://erp.tzaustria.info -portal_secret = secret +portal_url = https://dev-portal.tzaustria.info/ +portal_secret = hH43413$74O0 [queue_job] channels = root:4 diff --git a/dev/scripts/interfaces/sst01_portal_create_partner.py b/dev/scripts/interfaces/sst01_portal_create_partner.py index fac93c5c..31cadf94 100755 --- a/dev/scripts/interfaces/sst01_portal_create_partner.py +++ b/dev/scripts/interfaces/sst01_portal_create_partner.py @@ -23,7 +23,7 @@ values = { "phone": "+43 564564", "mobile": "+43 677 564564", "endkunde": True, - "portal_id": "333333", + "portal_id": "6", "company": "Bier AG", "info_uid": "habe keine", "info_kundennr": "K1234", diff --git a/dev/scripts/interfaces/sst10_create_product.py b/dev/scripts/interfaces/sst10_create_product.py index e4bb2d83..78ee6589 100755 --- a/dev/scripts/interfaces/sst10_create_product.py +++ b/dev/scripts/interfaces/sst10_create_product.py @@ -24,6 +24,7 @@ values = { "xcat_id": "Kategorie 1", "notes": "notes", "material_type_id": "Holz", + "categ_id": "all", "intrastat_id": "Code", "sale_ok": True, "assembly_line_ids": ["12345", "12346"], diff --git a/dev/scripts/interfaces/sst11_pg_create_company.py b/dev/scripts/interfaces/sst11_pg_create_company.py index fdb5f612..62531b2a 100755 --- a/dev/scripts/interfaces/sst11_pg_create_company.py +++ b/dev/scripts/interfaces/sst11_pg_create_company.py @@ -19,7 +19,7 @@ values = { "fax": "+43 55567051", "phone": "+43 5556705", "endkunde": True, - "portal_id": "111111", + "portal_id": "31", "email": "company@test.at", "opt_out": True, "ref": "A144S3", diff --git a/ext/custom-addons/dp_custom/__manifest__.py b/ext/custom-addons/dp_custom/__manifest__.py index 3888954f..9e7ddb65 100644 --- a/ext/custom-addons/dp_custom/__manifest__.py +++ b/ext/custom-addons/dp_custom/__manifest__.py @@ -38,12 +38,14 @@ 'data/dp_custom_data.xml', 'data/glaser_company_data.xml', 'data/tz_austria_company_data.xml', + 'data/product_data.xml', 'data/cron_job.xml', 'views/dp_custom_views.xml', 'views/res_line_views.xml', 'views/res_partner_views.xml', 'views/stock_views.xml', 'views/sale_views.xml', + 'views/account_views.xml', 'views/material_type_views.xml', 'views/product_views.xml', 'views/ir_attachment_views.xml', diff --git a/ext/custom-addons/dp_custom/data/product_data.xml b/ext/custom-addons/dp_custom/data/product_data.xml new file mode 100644 index 00000000..717de1f8 --- /dev/null +++ b/ext/custom-addons/dp_custom/data/product_data.xml @@ -0,0 +1,9 @@ + + + + + Rabatt + service + + + diff --git a/ext/custom-addons/dp_custom/models/__init__.py b/ext/custom-addons/dp_custom/models/__init__.py index 6f18c9e1..22281ea6 100644 --- a/ext/custom-addons/dp_custom/models/__init__.py +++ b/ext/custom-addons/dp_custom/models/__init__.py @@ -29,3 +29,4 @@ from . import sale from . import material_type from . import product from . import ir_attachment +from . import account diff --git a/ext/custom-addons/dp_custom/models/account.py b/ext/custom-addons/dp_custom/models/account.py new file mode 100644 index 00000000..6fcdfcf6 --- /dev/null +++ b/ext/custom-addons/dp_custom/models/account.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# datenpol gmbh +# Copyright (C) 2013-TODAY datenpol gmbh () +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from odoo import api, fields, models, _ + + +class AccountInvoiceLine(models.Model): + _inherit = 'account.invoice.line' + + intrastat_id = fields.Many2one(comodel_name='report.intrastat.code', string='Intrastat Code') + + @api.model + def create(self, vals): + if vals.get('product_id', False) and not vals.get('intrastat_id', False): + vals.update(intrastat_id=vals['product_id'].intrastat_id.id) + return super(AccountInvoiceLine, self).create(vals) + diff --git a/ext/custom-addons/dp_custom/models/product.py b/ext/custom-addons/dp_custom/models/product.py index bbce2220..fe94acc4 100644 --- a/ext/custom-addons/dp_custom/models/product.py +++ b/ext/custom-addons/dp_custom/models/product.py @@ -55,6 +55,7 @@ class ProductTemplate(models.Model): material_type_id = fields.Many2one(comodel_name='material.type', string='Materialtyp') assembly_line_ids = fields.Many2many(comodel_name='res.line', string='Produktionslinien') notes = fields.Text(string='Notizen') + can_be_sold_unconfigured = fields.Boolean(string='Darf unkonfiguriert verkauft werden') @api.model def create_product(self, vals): @@ -77,6 +78,14 @@ class ProductTemplate(models.Model): raise ValidationError( _("X-Kategorie \'%s\' kann nicht zugeordnet werden" % vals['xcat_id'])) + if vals.get('categ_id', False): + categ_id = self.env['product.category'].search([('code', '=', vals['categ_id'])]) + if categ_id: + vals['categ_id'] = categ_id.id + else: + raise ValidationError( + _("Kategorie \'%s\' kann nicht zugeordnet werden" % vals['categ_id'])) + if vals.get('material_type_id', False): material_type = self.env['material.type'].search([('name', '=', vals['material_type_id'])]) if material_type: @@ -110,7 +119,7 @@ class ProductTemplate(models.Model): def _get_specified_fields(self): return ['default_code', 'name', 'length', 'width', 'thickness', 'surface', 'active', 'weight', 'is_internal', 'xcat_id', 'notes', 'material_type_id', 'intrastat_id', 'sale_ok', 'assembly_line_ids', 'list_price', - 'height'] + 'height', 'categ_id'] class ProductCategory(models.Model): diff --git a/ext/custom-addons/dp_custom/models/res_partner.py b/ext/custom-addons/dp_custom/models/res_partner.py index ad2fdbb3..aca88d26 100644 --- a/ext/custom-addons/dp_custom/models/res_partner.py +++ b/ext/custom-addons/dp_custom/models/res_partner.py @@ -19,6 +19,7 @@ # ############################################################################## import requests +import json from odoo import tools, api, fields, models, _ from odoo.exceptions import ValidationError @@ -152,21 +153,25 @@ class Partner(models.Model): if not partner_id.portal_id: raise ValidationError(_("Der Partner mit der ID %s hat keine Portal-ID" % partner_id.id)) pricelist = partner_id.property_product_pricelist - data = {'portal_id': partner_id.portal_id, - 'rules': [] - } - for item in pricelist.items_ids: + data = [] + for item in pricelist.item_ids: if item.compute_price == 'percentage' and item.applied_on in ['3_global', '2_product_category', '1_product']: - category_code = item.product_tmpl_id.categ_id.code if item.applied_on == '2_product_category' else False - product_code = item.product_tmpl_id.default_code if item.applied_on == '1_product' else False - data['rules'].append({'category_code': category_code, - 'product_code': product_code, - 'factor': 1 - (item.percent_price / 100) - }) + code = False + if item.applied_on == '2_product_category': + code = item.categ_id.code + if item.applied_on == '1_product': + code = item.product_tmpl_id.default_code + data.append({ + 'customer_id': partner_id.portal_id, + 'code': code, + 'discount': 1 - (item.percent_price / 100) + }) portal_url = tools.config.get('portal_url') application_id = tools.config.get('portal_secret') - requests.post(portal_url + '/customer/api/v1/set-discounts/?secret=' + application_id, data=data) + response = requests.post(portal_url + '/api/v1/set-discounts/?secret=' + application_id, data=json.dumps(data)) + if response.status_code != 200: + raise ValidationError(_('Rabatt konnte nicht gesetzt werden.')) class PartnerSector(models.Model): diff --git a/ext/custom-addons/dp_custom/models/sale.py b/ext/custom-addons/dp_custom/models/sale.py index 52c50edb..8bc7203d 100644 --- a/ext/custom-addons/dp_custom/models/sale.py +++ b/ext/custom-addons/dp_custom/models/sale.py @@ -183,6 +183,7 @@ class SaleOrderLine(models.Model): lot_id = fields.Many2one(comodel_name='stock.production.lot', string='Lot') from_designbox = fields.Boolean(string='Import von Designbox', readonly=True) + product_id = fields.Many2one(domain=[('sale_ok', '=', True), ('can_be_sold_unconfigured', '=', True)]) @api.model def correct_values(self, vals): diff --git a/ext/custom-addons/dp_custom/views/account_views.xml b/ext/custom-addons/dp_custom/views/account_views.xml new file mode 100644 index 00000000..b1dc46bc --- /dev/null +++ b/ext/custom-addons/dp_custom/views/account_views.xml @@ -0,0 +1,15 @@ + + + + + account_invoice_form_view + account.invoice + + + + + + + + + diff --git a/ext/custom-addons/dp_custom/views/product_views.xml b/ext/custom-addons/dp_custom/views/product_views.xml index 704d1968..6d5e8160 100644 --- a/ext/custom-addons/dp_custom/views/product_views.xml +++ b/ext/custom-addons/dp_custom/views/product_views.xml @@ -5,6 +5,9 @@ product.template + + +
diff --git a/ext/custom-addons/dp_dmi/material.type.csv b/ext/custom-addons/dp_dmi/material.type.csv index 89718d24..4bf8a7d2 100644 --- a/ext/custom-addons/dp_dmi/material.type.csv +++ b/ext/custom-addons/dp_dmi/material.type.csv @@ -1,2 +1,6 @@ "id","name","print_default_code" -"dp_dmi.unique_material_id","Material Name","True" +"1","Trägermaterial","True" +"2","Laminat","True" +"3","Kante","True" +"4","Roh Material","True" +"5","Beschlag","True" diff --git a/ext/custom-addons/dp_dmi/res.line.csv b/ext/custom-addons/dp_dmi/res.line.csv index 07ec605c..7c262f5f 100644 --- a/ext/custom-addons/dp_dmi/res.line.csv +++ b/ext/custom-addons/dp_dmi/res.line.csv @@ -1,8 +1,13 @@ "id","name","description" +"l0000","0000","Desigbox Material" +"l0000I","0000I","Desigbox Material (internal)" "l0001","0001","TZ Austria" -"l0001I","0001","TZ Austria (internal)" +"l0001I","0001I","TZ Austria (internal)" "l0002","0002","TZ Bandung" "l0002I","0002I","TZ Bandung (internal)" "l0003","0003","TZ Malaysia" "l0003I","0003I","TZ Malaysia (internal)" - +"l9998","9998","Test Line 9998" +"l9998I","9998I","Test Line 9998 (internal)" +"l9999","9999","Test Line 9999" +"l9999I","9999I","Test Line 9999 (internal)" diff --git a/setup/lib/environments.py b/setup/lib/environments.py index 78c98aeb..feaa55d9 100644 --- a/setup/lib/environments.py +++ b/setup/lib/environments.py @@ -31,7 +31,7 @@ ENVIRONMENTS = { 'tzdev' : Environment('http://10.1.2.195', "8080", "tz-austria_1", "admin", "x", "admin", config = ConfigTZA()), 'tzdev-tz' : Environment('http://10.1.2.195', "8080", "tz-austria_1", "tz-admin", "x", "admin", config = ConfigTZA()), 'tzdev-glaser': Environment("http://10.1.2.195", "8080", "tz-austria_1", "glaser-admin", "x", "admin", config = ConfigGlaser()), - + 'oa' : Environment('http://localhost', "8080", "tz-austria_1", "admin", "x", "admin", config = ConfigTZA()), 'oa-tz' : Environment('http://localhost', "8080", "tz-austria_1", "tz-admin", "x", "admin", config = ConfigTZA()), 'oa-glaser' : Environment('http://localhost', "8080'" "tz-austria_1", "admin", "x", "admin", config = ConfigGlaser()), @@ -42,8 +42,9 @@ ENVIRONMENTS = { 'aa' : Environment('http://localhost', '8080', 'tz-austria_1', 'admin', 'x', 'admin', config = ConfigTZA()), 'aa-tz' : Environment('http://localhost', '8080', 'tz-austria_1', 'tz-admin', 'x', 'admin', config = ConfigTZA()), 'aa-glaser' : Environment('http://localhost', '8080', 'tz-austria_1', 'glaser-admin', 'x', 'admin', config = ConfigGlaser()), - + # Remote environments are always listed without passwords! # Do not store them here, you have to type them anyway! - 'test': Environment('https://tz-austria.datenpol.at', '443', 'tz-austria_1', 'admin'), + 'test': Environment('https://erp.tzaustria.info', '443', 'odoo-test', 'admin', config = ConfigTZA()), + 'test-glaser': Environment('https://erp.tzaustria.info', '443', 'odoo-test', 'glaser-admin', config = ConfigGlaser()), }