sale_confirm_warning: add sale_warn
This commit is contained in:
@@ -19,6 +19,8 @@ When you confirm a quotation, Odoo will open a small wizard where you will be ab
|
|||||||
* invoicing address,
|
* invoicing address,
|
||||||
* payment terms.
|
* payment terms.
|
||||||
|
|
||||||
|
It will also display the sale warning if the customer's company has one. And it is a blocker warning, the user won't be able to confirm the quotation.
|
||||||
|
|
||||||
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 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
|
This module has been written by Alexis de Lattre from Akretion
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
# © 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
# © 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from odoo import models, fields, api
|
from odoo import models, fields, api, _
|
||||||
|
from odoo.exceptions import UserError
|
||||||
|
from odoo.addons.base.res.res_partner import WARNING_MESSAGE
|
||||||
|
|
||||||
|
|
||||||
class SaleConfirm(models.TransientModel):
|
class SaleConfirm(models.TransientModel):
|
||||||
@@ -24,15 +26,21 @@ class SaleConfirm(models.TransientModel):
|
|||||||
show_partner_shipping_id = fields.Many2one(
|
show_partner_shipping_id = fields.Many2one(
|
||||||
related='partner_shipping_id', readonly=True,
|
related='partner_shipping_id', readonly=True,
|
||||||
string='Detailed Delivery Address')
|
string='Detailed Delivery Address')
|
||||||
|
sale_warn = fields.Selection(
|
||||||
|
WARNING_MESSAGE, 'Sale Warning Type', readonly=True)
|
||||||
|
sale_warn_msg = fields.Text(string='Sale Warning Message', readonly=True)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _prepare_default_get(self, order):
|
def _prepare_default_get(self, order):
|
||||||
|
partner = order.partner_id.commercial_partner_id
|
||||||
default = {
|
default = {
|
||||||
'sale_id': order.id,
|
'sale_id': order.id,
|
||||||
'client_order_ref': order.client_order_ref,
|
'client_order_ref': order.client_order_ref,
|
||||||
'payment_term_id': order.payment_term_id.id or False,
|
'payment_term_id': order.payment_term_id.id or False,
|
||||||
'partner_invoice_id': order.partner_invoice_id.id,
|
'partner_invoice_id': order.partner_invoice_id.id,
|
||||||
'partner_shipping_id': order.partner_shipping_id.id,
|
'partner_shipping_id': order.partner_shipping_id.id,
|
||||||
|
'sale_warn_msg': partner.sale_warn_msg,
|
||||||
|
'sale_warn': partner.sale_warn,
|
||||||
}
|
}
|
||||||
return default
|
return default
|
||||||
|
|
||||||
@@ -59,6 +67,12 @@ class SaleConfirm(models.TransientModel):
|
|||||||
@api.multi
|
@api.multi
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
|
partner = self.sale_id.partner_id.commercial_partner_id
|
||||||
|
if partner.sale_warn == 'block':
|
||||||
|
raise UserError(_(
|
||||||
|
"You cannot confirm this quotation because "
|
||||||
|
"customer '%s' has a blocker sale warning:\n\n%s")
|
||||||
|
% (partner.display_name, partner.sale_warn_msg))
|
||||||
vals = self._prepare_update_so()
|
vals = self._prepare_update_so()
|
||||||
self.sale_id.write(vals)
|
self.sale_id.write(vals)
|
||||||
# confirm sale order
|
# confirm sale order
|
||||||
|
|||||||
@@ -12,8 +12,12 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Confirm Order">
|
<form string="Confirm Order">
|
||||||
<div><p>At this stage, you have received the Purchase Order from the customer and you are about to convert the related quotation to an order.</p></div>
|
<div><p>At this stage, you have received the Purchase Order from the customer and you are about to convert the related quotation to an order.</p></div>
|
||||||
|
<group name="warn" groups="sale.group_warning_sale" attrs="{'invisible': ['|', ('sale_warn', '=', False), ('sale_warn', '=', 'no-message')]}" string="Warning" col="4">
|
||||||
|
<field name="sale_warn" nolabel="1"/>
|
||||||
|
<field name="sale_warn_msg" nolabel="1" colspan="3"/>
|
||||||
|
</group>
|
||||||
<group name="main">
|
<group name="main">
|
||||||
<field name="sale_id"/>
|
<field name="sale_id" invisible="1"/>
|
||||||
<field name="client_order_ref"/>
|
<field name="client_order_ref"/>
|
||||||
<field name="partner_invoice_id" context="{'default_type': 'invoice'}"
|
<field name="partner_invoice_id" context="{'default_type': 'invoice'}"
|
||||||
groups="sale.group_delivery_invoice_address"/>
|
groups="sale.group_delivery_invoice_address"/>
|
||||||
@@ -32,8 +36,7 @@
|
|||||||
</group>
|
</group>
|
||||||
<footer>
|
<footer>
|
||||||
<button type="object" name="confirm"
|
<button type="object" name="confirm"
|
||||||
string="Confirm Sale" class="btn-primary"/>
|
string="Confirm Sale" class="btn-primary" attrs="{'invisible': [('sale_warn', '=', 'block')]}"/>
|
||||||
or
|
|
||||||
<button special="cancel" string="Annuler" class="btn-default"/>
|
<button special="cancel" string="Annuler" class="btn-default"/>
|
||||||
</footer>
|
</footer>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user