diff --git a/ext/custom-addons/dp_custom/__manifest__.py b/ext/custom-addons/dp_custom/__manifest__.py index 58d48f37..adea23a7 100644 --- a/ext/custom-addons/dp_custom/__manifest__.py +++ b/ext/custom-addons/dp_custom/__manifest__.py @@ -46,6 +46,7 @@ 'wizards/wizard_confirm_production.xml', 'wizards/wizard_import_tzbox.xml', 'wizards/wizard_reset_order.xml', + 'wizards/wizard_sign_delivery.xml', 'wizards/portal_assign_company.xml', 'wizards/wizard_confirm_print_invoice.xml', 'security/security.xml', @@ -55,11 +56,13 @@ 'data/tz_tax_data.xml', 'data/cron_job.xml', 'data/tz_config_data.xml', + 'data/mail_template_data.xml', 'views/dp_template.xml', 'views/dp_custom_views.xml', 'views/res_line_views.xml', 'views/res_partner_views.xml', 'views/stock_views.xml', + 'views/stock_picking_views.xml', 'views/sale_views.xml', 'views/account_views.xml', 'views/material_type_views.xml', @@ -67,6 +70,7 @@ 'views/ir_attachment_views.xml', 'views/res_company_views.xml', 'views/res_users_views.xml', + 'views/delivery_view.xml', 'security/ir.model.access.csv', ], 'installable': True, diff --git a/ext/custom-addons/dp_custom/data/mail_template_data.xml b/ext/custom-addons/dp_custom/data/mail_template_data.xml new file mode 100644 index 00000000..24eb863e --- /dev/null +++ b/ext/custom-addons/dp_custom/data/mail_template_data.xml @@ -0,0 +1,89 @@ + + + + + Delivery: Info to Office + ${object.company_id.name} Delivery Order (Ref ${object.name or 'n/a' }) + ${object.partner_id.id} + + + ${(object.name or '').replace('/','_')} + ${object.partner_id.lang} + +

Dear ${object.partner_id.name},

+

We are glad to inform you that your order has been shipped.

+

+%if object.carrier_tracking_ref: + Your tracking reference: + %if object.carrier_tracking_url: + ${object.carrier_tracking_ref}. + %else: + ${object.carrier_tracking_ref}. + %endif +%endif +

+

Find your delivery order attached for more details.

+

Thank you,

+
+
+ + + Delivery: Custom Notification Email + ${object.subject} + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ ${object.record_name} + + ${user.company_id.name} +
+
+ + + + +
${object.body | safe}
+
+ + + + + +
${user.company_id.name}
${user.company_id.phone or ''}
+ % if user.company_id.email: + ${user.company_id.email}
+ % endif + % if user.company_id.website: + ${user.company_id.website} + % endif +
+
Powered by Odoo.
+
+
+
+
diff --git a/ext/custom-addons/dp_custom/i18n/de.po b/ext/custom-addons/dp_custom/i18n/de.po index ad901bde..02d69a5d 100644 --- a/ext/custom-addons/dp_custom/i18n/de.po +++ b/ext/custom-addons/dp_custom/i18n/de.po @@ -194,3 +194,39 @@ msgstr "" "Odoo hilft Ihnen alle Aktivitäten zu einem Kunden\n" "leicht zu überblicken: Diskussionen, Verlauf der \n" "Geschäftschancen, Dokumente, usw." + +#. module: dp_custom +#: model:mail.template,report_name:dp_custom.mail_template_data_confirmation_to_office +msgid "${(object.name or '').replace('/','_')}" +msgstr "${(object.name or '').replace('/','_')}" + +#. module: dp_custom +#: model:mail.template,subject:dp_custom.mail_template_data_confirmation_to_office +msgid "" +"${object.company_id.name} Delivery Order (Ref ${object.name or 'n/a' })" +msgstr "" +"${object.company_id.name} Lieferschein (Ref. ${object.name or 'n/a' })" + +#. module: dp_custom +#: model:mail.template,subject:dp_custom.mail_template_data_notification_to_office +msgid "${object.subject}" +msgstr "${object.subject}" + +#. module: dp_custom +#: model:mail.template,body_html:dp_custom.mail_template_data_confirmation_to_office +msgid "" +"\n" +"

Shopping Cart XYZ, Delivery Note ${object.name or 'n/a' } has been picked up by ${object.partner_id.name},

\n" +"

\n" +"

Find the delivery order attached for more details.

\n" +"

Thank you,

\n" +"
" +msgstr "" +"\n" +"

Der Warenkorb XYZ, Lieferschein ${object.name or 'n/a' } wurde von ${object.partner_id.name} abgeholt,

\n" +"

\n" +"

Weitere Informationen finden Sie im angehängten Lieferschein.

\n" +"

Vielen Dank,

\n" +"
" + + diff --git a/ext/custom-addons/dp_custom/models/__init__.py b/ext/custom-addons/dp_custom/models/__init__.py index bb776077..0c8a6c87 100644 --- a/ext/custom-addons/dp_custom/models/__init__.py +++ b/ext/custom-addons/dp_custom/models/__init__.py @@ -25,6 +25,7 @@ from . import res_partner from . import res_company from . import res_line from . import stock +from . import stock_picking from . import sale from . import material_type from . import product diff --git a/ext/custom-addons/dp_custom/models/ir_attachment.py b/ext/custom-addons/dp_custom/models/ir_attachment.py index 2c382102..4eb35dac 100644 --- a/ext/custom-addons/dp_custom/models/ir_attachment.py +++ b/ext/custom-addons/dp_custom/models/ir_attachment.py @@ -26,6 +26,7 @@ class Attachment(models.Model): _inherit = 'ir.attachment' from_designbox = fields.Boolean(string='Import von Designbox', readonly=True) + customer_signed = fields.Boolean(string='Unterschrift vom Kunden', readonly=True) @api.multi def write(self, vals): @@ -33,6 +34,9 @@ class Attachment(models.Model): if record.from_designbox and not self.env.user.has_group('dp_custom.group_allow_delete_so_attachments'): raise ValidationError( _("Dokumente, die aus der Designbox importiert wurden, können nicht gelöscht werden.")) + if record.customer_signed and not self.env.user.has_group('dp_custom.group_allow_delete_signature'): + raise ValidationError( + _("Unterschriften des Kunden können nicht gelöscht werden.")) return super(Attachment, self).write(vals) @@ -42,5 +46,8 @@ class Attachment(models.Model): if record.from_designbox and not self.env.user.has_group('dp_custom.group_allow_delete_so_attachments'): raise ValidationError( _("Dokumente, die aus der Designbox importiert wurden, können nicht gelöscht werden.")) + if record.customer_signed and not self.env.user.has_group('dp_custom.group_allow_delete_signature'): + raise ValidationError( + _("Unterschriften des Kunden 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 06798026..1c3b249f 100644 --- a/ext/custom-addons/dp_custom/models/res_partner.py +++ b/ext/custom-addons/dp_custom/models/res_partner.py @@ -80,7 +80,7 @@ class Partner(models.Model): 'Sobald das Unternehmen manuell zugewiesen wurde, ' 'wird das Flag wieder entfernt') line_ids = fields.Many2many(comodel_name='res.line', string='Produktionslinien') - portal_id = fields.Char(string='Portal-ID',copy=False) + portal_id = fields.Char(string='Portal-ID',copy=False,track_visibility='onchange') partner_sector_id = fields.Many2one(comodel_name='res.partner.sector', string='Branche') active = fields.Boolean(track_visibility='onchange') portal_export_pending = fields.Boolean(string='Portal Export ausständig') diff --git a/ext/custom-addons/dp_custom/models/stock.py b/ext/custom-addons/dp_custom/models/stock.py index 5cfd49a7..9120acfe 100644 --- a/ext/custom-addons/dp_custom/models/stock.py +++ b/ext/custom-addons/dp_custom/models/stock.py @@ -22,7 +22,7 @@ from odoo import fields, models, api, tools, _ from odoo.exceptions import ValidationError from odoo.tools.float_utils import float_compare, float_is_zero - +import base64 class StockProductionLot(models.Model): _inherit = 'stock.production.lot' @@ -54,13 +54,61 @@ class StockPicking(models.Model): _inherit = 'stock.picking' dlv_partner_ref = fields.Text(compute='_get_partner_ref', store=False, string='Interne Referenz') - picking_signature = fields.Binary(string='Customer Signature') + picking_signature = fields.Binary(string='Customer Signature', default=None) + shopping_cart_ref = fields.Text(compute='_get_shopping_cart_ref', store=True, string='Warenkorb') + + @api.multi + def write(self, vals): + + if 'picking_signature' in vals: + msg = '' + prime_signature = "" + if not vals['picking_signature'] or len(vals['picking_signature']) == 3012: + if self['picking_signature'] or len(self['picking_signature']) == 3012: + prime_signature = self['picking_signature'] + msg='Unterschrift wurde entfernt' + else: + if not self['picking_signature'] or len(self['picking_signature']) == 3012: + prime_signature = vals['picking_signature'] + msg='Lieferschein wurde unterschrieben' + elif vals['picking_signature'] != self['picking_signature'].decode(): + prime_signature = vals['picking_signature'] + msg='Unterschrift wurde geändert' + + if msg != '': +# signature2attach = [] + ps = prime_signature.encode('ascii') + signature2attach = { + "filename": r'Signature.jpg', + "binary" : ps + } + self.create_attachment(signature2attach) + self.message_post(body=msg) + + return super(StockPicking, self).write(vals) + + @api.model + def create_attachment(self, vals): + attachment_vals = { + 'name': vals['filename'], + 'datas': vals['binary'], + 'datas_fname': vals['filename'], + 'res_model': self._name, + 'res_id': self.id, + 'customer_signed' : True, + } + self.env['ir.attachment'].create(attachment_vals) @api.multi def _get_partner_ref(self): for record in self: record.dlv_partner_ref = record.partner_id.ref + @api.multi + def _get_shopping_cart_ref(self): + for record in self: + record.shopping_cart_ref = record.sale_id.origin + @api.model def _formatLang(self, value): lang = self.partner_id.lang diff --git a/ext/custom-addons/dp_custom/models/stock_picking.py b/ext/custom-addons/dp_custom/models/stock_picking.py new file mode 100644 index 00000000..10d1875f --- /dev/null +++ b/ext/custom-addons/dp_custom/models/stock_picking.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import models, fields, api, _ +from odoo.exceptions import UserError + + +class StockPicking(models.Model): + _inherit = 'stock.picking' + + @api.multi + def action_send_confirmation_to_office(self): + self.ensure_one() + delivery_template_id = self.env.ref('dp_custom.mail_template_data_confirmation_to_office').id + compose_form_id = self.env.ref('mail.email_compose_message_wizard_form').id + ctx = dict( + default_composition_mode='comment', + default_res_id=self.id, + default_model='stock.picking', + default_use_template=bool(delivery_template_id), + default_template_id=delivery_template_id, + custom_layout='dp_custom.mail_template_data_notification_to_office' + ) + return { + 'type': 'ir.actions.act_window', + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'mail.compose.message', + 'view_id': compose_form_id, + 'target': 'new', + 'context': ctx, + } + diff --git a/ext/custom-addons/dp_custom/security/security.xml b/ext/custom-addons/dp_custom/security/security.xml index 8f0cf0aa..302b6296 100644 --- a/ext/custom-addons/dp_custom/security/security.xml +++ b/ext/custom-addons/dp_custom/security/security.xml @@ -1,5 +1,9 @@ + + Löschen von Unterschriften in Lieferscheinen erlauben + Löschen von Unterschriften in Lieferscheinen erlauben + Löschen von Anhängen in Angeboten erlauben Löschen von Anhängen in Angeboten erlauben diff --git a/ext/custom-addons/dp_custom/views/delivery_view.xml b/ext/custom-addons/dp_custom/views/delivery_view.xml new file mode 100644 index 00000000..e2ccfbd0 --- /dev/null +++ b/ext/custom-addons/dp_custom/views/delivery_view.xml @@ -0,0 +1,17 @@ + + + + + delivery.stock.picking_withcarrier.form.view + stock.picking + + + + +