Prospect modules (different approch than the OCA module partner_prospect in sale-workflow)
This commit is contained in:
3
base_partner_prospect/__init__.py
Normal file
3
base_partner_prospect/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import partner
|
||||
30
base_partner_prospect/__manifest__.py
Normal file
30
base_partner_prospect/__manifest__.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# -*- 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': 'Base Partner Prospect',
|
||||
'version': '10.0.1.0.0',
|
||||
'category': 'Partner',
|
||||
'license': 'AGPL-3',
|
||||
'summary': "Add boolean field 'Prospect' on partners",
|
||||
'description': """
|
||||
Base Partner Prospect
|
||||
=====================
|
||||
|
||||
This module adds a regular boolean field *Prospect* on partner form view.
|
||||
|
||||
This module is a different implementation of the OCA module *partner_prospect* which adds the same field on partners: that module doesn't use a regular boolean field but a compute boolean field. I don't like this approch because I want to have manual control over that field and have a customer with prospect = False even if there is not sale order in Odoo for that customer.
|
||||
|
||||
This module has been written by Alexis de Lattre from Akretion
|
||||
<alexis.delattre@akretion.com>.
|
||||
""",
|
||||
'author': 'Akretion',
|
||||
'website': 'http://www.akretion.com',
|
||||
'depends': ['base'],
|
||||
'data': [
|
||||
'partner_view.xml',
|
||||
],
|
||||
'installable': True,
|
||||
}
|
||||
31
base_partner_prospect/partner.py
Normal file
31
base_partner_prospect/partner.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# -*- 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, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = 'res.partner'
|
||||
|
||||
prospect = fields.Boolean(
|
||||
string='Is a Prospect', track_visibility='onchange')
|
||||
|
||||
@api.onchange('customer')
|
||||
def prospect_customer_change(self):
|
||||
if self.customer and self.prospect:
|
||||
self.prospect = False
|
||||
|
||||
@api.onchange('prospect')
|
||||
def prospect_change(self):
|
||||
if self.prospect and self.customer:
|
||||
self.customer = False
|
||||
|
||||
@api.constrains('customer', 'prospect')
|
||||
def partner_prospect_check(self):
|
||||
for partner in self:
|
||||
if partner.customer and partner.prospect:
|
||||
raise ValidationError(_(
|
||||
"Partner '%s' cannot be both a prospect and a customer")
|
||||
% self.name_get()[0][1])
|
||||
41
base_partner_prospect/partner_view.xml
Normal file
41
base_partner_prospect/partner_view.xml
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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_partner_form" model="ir.ui.view">
|
||||
<field name="name">base_usability.title.on.partner.form</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page[@name='sales_purchases']//group[@name='sale']/field[@name='customer']" position="after">
|
||||
<field name="prospect"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_res_partner_filter" model="ir.ui.view">
|
||||
<field name="name">base_usability.partner.search.form</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref="base.view_res_partner_filter"/>
|
||||
<field name="arch" type="xml">
|
||||
<filter name="customer" position="after">
|
||||
<filter name="prospect" string="Prospects" domain="[('prospect', '=', True), ('parent_id', '=', False)]"/>
|
||||
</filter>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="partner_prospect_action" model="ir.actions.act_window">
|
||||
<field name="name">Prospects</field>
|
||||
<field name="res_model">res.partner</field>
|
||||
<field name="view_mode">tree,form,kanban</field>
|
||||
<field name="context">{'default_prospect': 1, 'search_default_prospect': 1}</field>
|
||||
</record>
|
||||
|
||||
<!-- I don't add a menu entry ; it should be added in custom module if needed -->
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user