diff --git a/beesdoo_base/__init__.py b/beesdoo_base/__init__.py new file mode 100644 index 0000000..4001611 --- /dev/null +++ b/beesdoo_base/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +import models +import tools \ No newline at end of file diff --git a/beesdoo_base/__openerp__.py b/beesdoo_base/__openerp__.py new file mode 100644 index 0000000..b39b36c --- /dev/null +++ b/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', + ], +} diff --git a/beesdoo_base/models/__init__.py b/beesdoo_base/models/__init__.py new file mode 100644 index 0000000..751e194 --- /dev/null +++ b/beesdoo_base/models/__init__.py @@ -0,0 +1 @@ +import partner \ No newline at end of file diff --git a/beesdoo_base/models/partner.py b/beesdoo_base/models/partner.py new file mode 100644 index 0000000..970a34c --- /dev/null +++ b/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) diff --git a/beesdoo_base/tools/__init__.py b/beesdoo_base/tools/__init__.py new file mode 100644 index 0000000..64ec8c0 --- /dev/null +++ b/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)) diff --git a/beesdoo_base/views/partner.xml b/beesdoo_base/views/partner.xml new file mode 100644 index 0000000..12cef3f --- /dev/null +++ b/beesdoo_base/views/partner.xml @@ -0,0 +1,15 @@ + + + + beesdoo.partner.form.view + res.partner + + + + + + + + + + \ No newline at end of file