diff --git a/ext/custom-addons/dp_custom/__manifest__.py b/ext/custom-addons/dp_custom/__manifest__.py index 033fbd75..769c3272 100644 --- a/ext/custom-addons/dp_custom/__manifest__.py +++ b/ext/custom-addons/dp_custom/__manifest__.py @@ -45,6 +45,7 @@ 'views/sale_views.xml', 'views/material_type_views.xml', 'views/product_views.xml', + 'views/ir_attachment_views.xml', 'security/ir.model.access.csv', ], 'installable': True, diff --git a/ext/custom-addons/dp_custom/models/__init__.py b/ext/custom-addons/dp_custom/models/__init__.py index 4d297f47..6f18c9e1 100644 --- a/ext/custom-addons/dp_custom/models/__init__.py +++ b/ext/custom-addons/dp_custom/models/__init__.py @@ -28,3 +28,4 @@ from . import stock from . import sale from . import material_type from . import product +from . import ir_attachment diff --git a/ext/custom-addons/dp_custom/models/ir_attachment.py b/ext/custom-addons/dp_custom/models/ir_attachment.py new file mode 100644 index 00000000..5f0cc232 --- /dev/null +++ b/ext/custom-addons/dp_custom/models/ir_attachment.py @@ -0,0 +1,46 @@ +# -*- 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 models, fields, api, _ +from odoo.exceptions import ValidationError + + +class Attachment(models.Model): + _inherit = 'ir.attachment' + + from_designbox = fields.Boolean(string='Import von Designbox', readonly=True) + + @api.multi + def write(self, vals): + for record in self: + if record.from_designbox: + raise ValidationError( + _("Dokumente, die aus der Designbox importiert wurden, können nicht gelöscht werden.")) + + return super(Attachment, self).write(vals) + + @api.multi + def unlink(self): + for record in self: + if record.from_designbox: + raise ValidationError( + _("Dokumente, die aus der Designbox importiert wurden, können nicht gelöscht werden.")) + + return super(Attachment, self).unlink() diff --git a/ext/custom-addons/dp_custom/models/res_partner.py b/ext/custom-addons/dp_custom/models/res_partner.py index 910f3acc..de046354 100644 --- a/ext/custom-addons/dp_custom/models/res_partner.py +++ b/ext/custom-addons/dp_custom/models/res_partner.py @@ -36,9 +36,9 @@ class PartnerEventListener(Component): if record.active and record.portal_id: if 'property_product_pricelist' in fields: for contact in record.child_ids: - self.env['product.pricelist.item'].with_delay().job_export_portal_price(contact) + self.env['res.partner'].with_delay().job_export_portal_price(contact) if 'parent_id' in fields: - self.env['product.pricelist.item'].with_delay().job_export_portal_price(record) + self.env['res.partner'].with_delay().job_export_portal_price(record) class Partner(models.Model): diff --git a/ext/custom-addons/dp_custom/models/sale.py b/ext/custom-addons/dp_custom/models/sale.py index 199fbb74..52c50edb 100644 --- a/ext/custom-addons/dp_custom/models/sale.py +++ b/ext/custom-addons/dp_custom/models/sale.py @@ -106,7 +106,7 @@ class SaleOrder(models.Model): order_id = self.create(vals) if attachment_vals: order_id.pg_create_sale_order_attachments(attachment_vals) - if attachment_vals: + if order_line_vals: order_id.pg_create_order_lines(order_line_vals) return {'id': order_id.id, 'name': order_id.name} @@ -144,7 +144,8 @@ class SaleOrder(models.Model): 'product_id': vals['product_id'], 'price_unit': vals['price_unit'], 'product_uom_qty': vals['product_uom_qty'], - 'lot_id': lot_id + 'lot_id': lot_id, + 'from_designbox': True, })) return order_lines @@ -153,6 +154,7 @@ class SaleOrder(models.Model): attachment_vals = { 'name': vals['filename'], 'datas': vals['binary'], + 'from_designbox': True, 'datas_fname': vals['filename'], 'res_model': record._name, 'res_id': record.id, @@ -180,6 +182,7 @@ class SaleOrderLine(models.Model): _inherit = 'sale.order.line' lot_id = fields.Many2one(comodel_name='stock.production.lot', string='Lot') + from_designbox = fields.Boolean(string='Import von Designbox', readonly=True) @api.model def correct_values(self, vals): diff --git a/ext/custom-addons/dp_custom/views/ir_attachment_views.xml b/ext/custom-addons/dp_custom/views/ir_attachment_views.xml new file mode 100644 index 00000000..e308a379 --- /dev/null +++ b/ext/custom-addons/dp_custom/views/ir_attachment_views.xml @@ -0,0 +1,13 @@ + + + + ir_attachment_form_view + ir.attachment + + + + + + + + diff --git a/ext/custom-addons/dp_custom/views/sale_views.xml b/ext/custom-addons/dp_custom/views/sale_views.xml index 072f60f8..6afc32c2 100644 --- a/ext/custom-addons/dp_custom/views/sale_views.xml +++ b/ext/custom-addons/dp_custom/views/sale_views.xml @@ -19,12 +19,15 @@ + + +