diff --git a/sale_confirm_wizard/__init__.py b/sale_confirm_wizard/__init__.py new file mode 100644 index 0000000..3b4c3ed --- /dev/null +++ b/sale_confirm_wizard/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import wizard diff --git a/sale_confirm_wizard/__manifest__.py b/sale_confirm_wizard/__manifest__.py new file mode 100644 index 0000000..20759b7 --- /dev/null +++ b/sale_confirm_wizard/__manifest__.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# © 2017 Akretion (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Sale Confirm Wizard', + 'version': '10.0.1.0.0', + 'category': 'Sale Management', + 'license': 'AGPL-3', + 'summary': 'Open a wizard when you confirm a sale order to update important info', + 'description': """ +Sale Confirm Wizard +=================== + +When you confirm a quotation, Odoo will open a small wizard where you will be able to check and update important information: + +* customer PO number, +* delivery address, +* invoicing address, +* payment terms. + +This module has been developped because the experience has shown, when a sales assistant confirms a quotation in Odoo, it overlooks the important information written in the customer PO that may be different from the information of the quotation in Odoo, which causes many errors in delivery and invoicing. + +This module has been written by Alexis de Lattre from Akretion +. + """, + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'depends': ['sale'], + 'data': [ + 'wizard/sale_confirm_view.xml', + 'sale_view.xml', + ], + 'installable': True, +} diff --git a/sale_confirm_wizard/sale_view.xml b/sale_confirm_wizard/sale_view.xml new file mode 100644 index 0000000..7aa163f --- /dev/null +++ b/sale_confirm_wizard/sale_view.xml @@ -0,0 +1,25 @@ + + + + + + + sale.confirm.wizard.sale_order_form + sale.order + + + + + + + + diff --git a/sale_confirm_wizard/wizard/__init__.py b/sale_confirm_wizard/wizard/__init__.py new file mode 100644 index 0000000..6b461c2 --- /dev/null +++ b/sale_confirm_wizard/wizard/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import sale_confirm diff --git a/sale_confirm_wizard/wizard/sale_confirm.py b/sale_confirm_wizard/wizard/sale_confirm.py new file mode 100644 index 0000000..e9d1c8e --- /dev/null +++ b/sale_confirm_wizard/wizard/sale_confirm.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- +# © 2017 Akretion (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models, fields, api + + +class SaleConfirm(models.TransientModel): + _name = 'sale.confirm' + _description = 'Wizard to confirm a sale order' + + sale_id = fields.Many2one( + 'sale.order', string='Sale Order', readonly=True) + client_order_ref = fields.Char(string='Customer PO Number') + payment_term_id = fields.Many2one( + 'account.payment.term', string='Payment Terms') + partner_invoice_id = fields.Many2one( + 'res.partner', 'Invoice Address', required=True) + show_partner_invoice_id = fields.Many2one( + related='partner_invoice_id', readonly=True, + string='Detailed Invoice Address') + partner_shipping_id = fields.Many2one( + 'res.partner', 'Delivery Address', required=True) + show_partner_shipping_id = fields.Many2one( + related='partner_shipping_id', readonly=True, + string='Detailed Delivery Address') + + @api.model + def _prepare_default_get(self, order): + default = { + 'sale_id': order.id, + 'client_order_ref': order.client_order_ref, + 'payment_term_id': order.payment_term_id.id or False, + 'partner_invoice_id': order.partner_invoice_id.id, + 'partner_shipping_id': order.partner_shipping_id.id, + } + return default + + @api.model + def default_get(self, fields): + res = super(SaleConfirm, self).default_get(fields) + assert self._context.get('active_model') == 'sale.order',\ + 'active_model should be sale.order' + order = self.env['sale.order'].browse(self._context.get('active_id')) + default = self._prepare_default_get(order) + res.update(default) + return res + + @api.multi + def _prepare_update_so(self): + self.ensure_one() + return { + 'client_order_ref': self.client_order_ref, + 'payment_term_id': self.payment_term_id.id or False, + 'partner_invoice_id': self.partner_invoice_id.id, + 'partner_shipping_id': self.partner_shipping_id.id, + } + + @api.multi + def confirm(self): + self.ensure_one() + vals = self._prepare_update_so() + self.sale_id.write(vals) + # confirm sale order + self.sale_id.action_confirm() + return True diff --git a/sale_confirm_wizard/wizard/sale_confirm_view.xml b/sale_confirm_wizard/wizard/sale_confirm_view.xml new file mode 100644 index 0000000..97d02e9 --- /dev/null +++ b/sale_confirm_wizard/wizard/sale_confirm_view.xml @@ -0,0 +1,50 @@ + + + + + + + sale.confirm.form + sale.confirm + +
+

At this stage, you have received the Purchase Order from the customer and you are about to convert the related quotation to an order.

+ + + + + + + + + + +
+
+
+
+
+ + + Confirm Order + sale.confirm + form + new + + +