Port sale_crm_usability to v10

This commit is contained in:
Alexis de Lattre
2017-12-04 16:10:23 +01:00
parent 522d3d5aa0
commit 5d1df0b654
7 changed files with 96 additions and 122 deletions

View File

@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
from . import crm_make_sale
from . import crm_lead_lost

View File

@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# © 2017 Akretion (http://www.akretion.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# @author Alexis de Lattre <alexis.delattre@akretion.com>
from odoo import models, fields, api, _
class CrmLeadLost(models.TransientModel):
_inherit = 'crm.lead.lost'
cancel_quotes = fields.Boolean(
string='Cancel Related Quotations', default=True)
@api.multi
def action_lost_reason_apply(self):
assert self._context.get('active_model') == 'crm.lead', 'wrong model'
leads = self.env['crm.lead'].browse(self._context.get('active_ids'))
if self.cancel_quotes and leads:
quotes = self.env['sale.order'].search([
('opportunity_id', 'in', leads.ids),
('state', 'in', ('draft', 'sent')),
])
if quotes:
quotes.action_cancel()
quotes.message_post(_(
"Quotation automatically cancelled upon marking "
"the related opportunity as lost."))
return super(CrmLeadLost, self).action_lost_reason_apply()

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="crm_lead_lost_view_form" model="ir.ui.view">
<field name="name">sale_crm_usability.crm.lead.lost.form</field>
<field name="model">crm.lead.lost</field>
<field name="inherit_id" ref="crm.crm_lead_lost_view_form"/>
<field name="arch" type="xml">
<field name="lost_reason_id" position="after">
<field name="cancel_quotes"/>
</field>
</field>
</record>
</odoo>

View File

@@ -1,22 +0,0 @@
# -*- coding: utf-8 -*-
# © 2016 Akretion (http://www.akretion.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# @author Alexis de Lattre <alexis.delattre@akretion.com>
from openerp import models, api
class CrmMakeSale(models.TransientModel):
_inherit = 'crm.make.sale'
@api.multi
def makeOrder(self):
# the button to start this wizard is only available in form view
# This code should be updated when we will have a _prepare method
# in the create of the sale order
self.ensure_one()
value = super(CrmMakeSale, self).makeOrder()
if value.get('res_model') == 'sale.order' and value.get('res_id'):
so = self.env['sale.order'].browse(value['res_id'])
so.lead_id = self._context.get('active_id')
return value