Browse Source

[ADD] S0006 : first_name and last_name on res_partner

pull/1/head
Thibault Francois 9 years ago
parent
commit
2ad1e2386a
  1. 3
      beesdoo_base/__init__.py
  2. 23
      beesdoo_base/__openerp__.py
  3. 1
      beesdoo_base/models/__init__.py
  4. 14
      beesdoo_base/models/partner.py
  5. 8
      beesdoo_base/tools/__init__.py
  6. 15
      beesdoo_base/views/partner.xml

3
beesdoo_base/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
import models
import tools

23
beesdoo_base/__openerp__.py

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
{
'name': "Beescoop Base Module",
'summary': """
Module that customize the base module and contains some python tools
""",
'description': """
""",
'author': "Beescoop - Cellule IT",
'website': "https://github.com/beescoop/Obeesdoo",
'category': 'Project Management',
'version': '0.1',
'depends': ['base'],
'data': [
'views/partner.xml',
],
}

1
beesdoo_base/models/__init__.py

@ -0,0 +1 @@
import partner

14
beesdoo_base/models/partner.py

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
from openerp import models, fields, api
from openerp.addons.beesdoo_base.tools import concat_names
class Partner(models.Model):
_inherit = 'res.partner'
first_name = fields.Char('First Name')
last_name = fields.Char('Last Name', required=True)
@api.onchange('first_name', 'last_name')
def _on_change_name(self):
self.name = concat_names(self.first_name, self.last_name)

8
beesdoo_base/tools/__init__.py

@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
def concat_names(*args):
"""
Concatenate only args that are not empty
@param args: a list of string
"""
return ' '.join(filter(bool, args))

15
beesdoo_base/views/partner.xml

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="ir.ui.view" id="beesdoo_partner_form_view">
<field name="name">beesdoo.partner.form.view</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml" >
<field name="name" position="replace">
<field name="name" class="oe_read_only" />
<field name="first_name" placeholder="First Name" class="oe_edit_only" />
<field name="last_name" placeholder="Last Name" class="oe_edit_only" default_focus="1"/>
</field>
</field>
</record>
</odoo>
Loading…
Cancel
Save