Browse Source

partner_sector: allow to use in individuals

pull/619/head
Jordi Ballester Alomar 6 years ago
committed by mreficent
parent
commit
a2af8ad628
  1. 12
      partner_sector/README.rst
  2. 3
      partner_sector/__manifest__.py
  3. 2
      partner_sector/models/__init__.py
  4. 14
      partner_sector/models/base_config_settings.py
  5. 14
      partner_sector/models/sale_config_settings.py
  6. 7
      partner_sector/security/partner_sector_security.xml
  7. 21
      partner_sector/views/base_config_settings.xml
  8. 55
      partner_sector/views/res_partner_view.xml
  9. 19
      partner_sector/views/sale_config_settings.xml

12
partner_sector/README.rst

@ -16,6 +16,15 @@ To manage sectors, you need to:
* Go to *Sales > Configuration > Contacts > Sectors*.
By default only companies have sectors. To activate sectors in individuals also,
you need to activate the following setting:
* Go to *Settings > General Settings > Sector in contacts > Use sector for individuals*
Or, if you have *Sales* or *CRM* modules installed:
* Go to *Sales > Configuration > Settings > Partner Sector > Use sector for individuals*
Usage
=====
@ -24,8 +33,6 @@ To use this module, you need to:
* Go to any partner's form.
Only companies have sectors.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
@ -56,6 +63,7 @@ Contributors
* Vicent Cubells <vicent.cubells@tecnativa.com>
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Luis M. Ontalba <luis.martinez@tecnativa.com>
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
Maintainer
----------

3
partner_sector/__manifest__.py

@ -18,7 +18,10 @@
],
"data": [
"security/ir.model.access.csv",
"security/partner_sector_security.xml",
"views/res_partner_sector_view.xml",
"views/res_partner_view.xml",
"views/base_config_settings.xml",
"views/sale_config_settings.xml"
]
}

2
partner_sector/models/__init__.py

@ -5,3 +5,5 @@
from . import res_partner
from . import res_partner_sector
from . import base_config_settings
from . import sale_config_settings

14
partner_sector/models/base_config_settings.py

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
from odoo import fields, models
class BaseConfigSettings(models.TransientModel):
_inherit = 'base.config.settings'
group_use_partner_sector_for_person = fields.Boolean(
'Use sector for individuals',
help="Set if you want to be able use sectors for "
"individuals also.",
implied_group='partner_sector.group_use_partner_sector_for_person')

14
partner_sector/models/sale_config_settings.py

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
from odoo import fields, models
class SaleConfigSettings(models.TransientModel):
_inherit = 'sale.config.settings'
group_use_partner_sector_for_person = fields.Boolean(
'Use sector for individuals',
help="Set if you want to be able to use sectors for "
"individuals also.",
implied_group='partner_sector.group_use_partner_sector_for_person')

7
partner_sector/security/partner_sector_security.xml

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="group_use_partner_sector_for_person" model="res.groups">
<field name="name">Use sector for individuals</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>
</odoo>

21
partner_sector/views/base_config_settings.xml

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_general_configuration" model="ir.ui.view">
<field name="name">General Settings</field>
<field name="model">base.config.settings</field>
<field name="inherit_id" ref="base_setup.view_general_configuration"/>
<field name="arch" type="xml">
<group name="authentication" position="after">
<group name="partner">
<label for="id" string="Sector for individual"/>
<div name="group_use_partner_sector_for_person">
<field name="group_use_partner_sector_for_person" class="oe_inline"/>
<label for="group_use_partner_sector_for_person"/>
</div>
</group>
</group>
</field>
</record>
</odoo>

55
partner_sector/views/res_partner_view.xml

@ -15,6 +15,14 @@
<field name="secondary_sector_ids" widget="many2many_tags"
attrs="{'invisible': [('is_company', '=', False)]}"/>
</field>
<xpath expr="//field[@name='child_ids']/form//field[@name='title']" position="after">
<field name="is_company" invisible="1"/>
<field name="sector_id" placeholder="Sector"
options='{"no_open": True}'
attrs="{'invisible': [('is_company', '=', False)]}"/>
<field name="secondary_sector_ids" widget="many2many_tags"
attrs="{'invisible': [('is_company', '=', False)]}"/>
</xpath>
</field>
</record>
@ -50,4 +58,51 @@
</field>
</record>
<!-- Views activated for group_use_partner_sector_for_person -->
<record model="ir.ui.view" id="view_partner_form_sector_person">
<field name="name">Partner form with sector</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="partner_sector.view_partner_form_sector"/>
<field name="groups_id" eval="[(4, ref('partner_sector.group_use_partner_sector_for_person'))]"/>
<field name="arch" type="xml">
<field name="sector_id" position="attributes">
<attribute name="attrs">{'invisible': 0}</attribute>
</field>
<field name="secondary_sector_ids" position="attributes">
<attribute name="attrs">{'invisible': 0}</attribute>
</field>
<xpath expr="//field[@name='child_ids']/form//field[@name='sector_id']" position="attributes">
<attribute name="attrs">{'invisible': 0}</attribute>
</xpath>
<xpath expr="//field[@name='child_ids']/form//field[@name='secondary_sector_ids']" position="attributes">
<attribute name="attrs">{'invisible': 0}</attribute>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="view_partner_tree_sector_person">
<field name="name">Partner tree with sector</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="partner_sector.view_partner_tree_sector"/>
<field name="groups_id" eval="[(4, ref('partner_sector.group_use_partner_sector_for_person'))]"/>
<field name="arch" type="xml">
<field name="sector_id" position="attributes">
<attribute name="attrs">{'invisible': 0}</attribute>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_res_partner_filter_sector_person">
<field name="name">Partner search with sector</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="partner_sector.view_res_partner_filter_sector"/>
<field name="groups_id" eval="[(4, ref('partner_sector.group_use_partner_sector_for_person'))]"/>
<field name="arch" type="xml">
<filter name="sector" position="attributes">
<attribute name="domain"/>
</filter>
</field>
</record>
</odoo>

19
partner_sector/views/sale_config_settings.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_sale_config_settings" model="ir.ui.view">
<field name="name">partner sector settings</field>
<field name="model">sale.config.settings</field>
<field name="inherit_id" ref="sales_team.view_sale_config_settings"/>
<field name="arch" type="xml">
<div id="main" position="inside">
<group name="partner_sector" string="Partner Sector">
<label for="id" string="Sector for individuals"/>
<div name="group_use_partner_sector_for_person">
<field name="group_use_partner_sector_for_person" class="oe_inline"/>
<label for="group_use_partner_sector_for_person"/>
</div>
</group>
</div>
</field>
</record>
</odoo>
Loading…
Cancel
Save