Prospect modules (different approch than the OCA module partner_prospect in sale-workflow)
This commit is contained in:
3
sale_partner_prospect/__init__.py
Normal file
3
sale_partner_prospect/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import sale
|
||||
29
sale_partner_prospect/__manifest__.py
Normal file
29
sale_partner_prospect/__manifest__.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2017 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
'name': 'Sale Partner Prospect',
|
||||
'version': '10.0.1.0.0',
|
||||
'category': 'Sales',
|
||||
'license': 'AGPL-3',
|
||||
'summary': "Glue module between base_partner_prospect and sale modules",
|
||||
'description': """
|
||||
Sale Partner Prospect
|
||||
=====================
|
||||
|
||||
This is a glue module between *base_partner_prospect* and *sale* modules. When you confirm a sale order, the partner will be converted from a prospect to a customer.
|
||||
|
||||
This module has been written by Alexis de Lattre from Akretion
|
||||
<alexis.delattre@akretion.com>.
|
||||
""",
|
||||
'author': 'Akretion',
|
||||
'website': 'http://www.akretion.com',
|
||||
'depends': ['sale', 'base_partner_prospect'],
|
||||
'data': [
|
||||
'sale_view.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'auto_install': True,
|
||||
}
|
||||
28
sale_partner_prospect/sale.py
Normal file
28
sale_partner_prospect/sale.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2015-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, api, _
|
||||
|
||||
|
||||
class SaleOrder(models.Model):
|
||||
_inherit = 'sale.order'
|
||||
|
||||
@api.multi
|
||||
def action_confirm(self):
|
||||
vals = {
|
||||
'prospect': False,
|
||||
'customer': True}
|
||||
for order in self:
|
||||
msg = _(
|
||||
'Validation of sale order %s triggered the conversion '
|
||||
'of this partner from prospect to customer.') % order.name
|
||||
if order.partner_id.prospect:
|
||||
order.partner_id.write(vals)
|
||||
order.partner_id.message_post(msg)
|
||||
if (
|
||||
order.partner_id.parent_id and
|
||||
order.partner_id.commercial_partner_id.prospect):
|
||||
order.partner_id.commercial_partner_id.write(vals)
|
||||
order.partner_id.commercial_partner_id.message_post(msg)
|
||||
return super(SaleOrder, self).action_confirm()
|
||||
32
sale_partner_prospect/sale_view.xml
Normal file
32
sale_partner_prospect/sale_view.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
© 2017 Akretion (http://www.akretion.com/)
|
||||
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
<record id="view_order_form" model="ir.ui.view">
|
||||
<field name="name">sale_partner_prospect.sale.order.form</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="partner_id" position="attributes">
|
||||
<attribute name="domain">['|', ('prospect', '=', True), ('customer', '=', True)]</attribute>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="res_partner_view_buttons" model="ir.ui.view">
|
||||
<field name="name">sale_partner_prospect.partner.form</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref="sale.res_partner_view_buttons"/>
|
||||
<field name="arch" type="xml">
|
||||
<button name="%(sale.act_res_partner_2_sale_order)d" position="attributes">
|
||||
<attribute name="attrs">{'invisible': [('prospect', '=', False), ('customer', '=', False)]}</attribute>
|
||||
</button>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user