Browse Source
[ADD] Split firstname feature in a new module and change the name of the field to fit the community module with the same name. This module will shadow partner_firstname and thus remove the cheesy feature
pull/53/head
[ADD] Split firstname feature in a new module and change the name of the field to fit the community module with the same name. This module will shadow partner_firstname and thus remove the cheesy feature
pull/53/head
Thibault Francois
7 years ago
12 changed files with 105 additions and 39 deletions
-
1beesdoo_base/__init__.py
-
2beesdoo_base/__openerp__.py
-
18beesdoo_base/models/partner.py
-
8beesdoo_base/report/beescard.xml
-
8beesdoo_base/tools/__init__.py
-
8beesdoo_base/views/partner.xml
-
2beesdoo_pos/models/beesdoo_pos.py
-
2partner_firstname/__init__.py
-
24partner_firstname/__openerp__.py
-
1partner_firstname/models/__init__.py
-
53partner_firstname/models/partner.py
-
17partner_firstname/views/res_partner.xml
@ -1,5 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
import models |
|||
import wizard |
|||
import tools |
|||
import controllers |
@ -1,8 +0,0 @@ |
|||
# -*- 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)) |
@ -0,0 +1,2 @@ |
|||
# -*- coding: utf-8 -*- |
|||
import models |
@ -0,0 +1,24 @@ |
|||
# -*- coding: utf-8 -*- |
|||
{ |
|||
'name': "Beescoop Base Module", |
|||
|
|||
'summary': """ |
|||
Module that simply add a firstname on the module res.partner |
|||
replace the community module from the same name for the beescoop |
|||
""", |
|||
|
|||
'description': """ |
|||
""", |
|||
|
|||
'author': "Beescoop - Cellule IT", |
|||
'website': "https://github.com/beescoop/Obeesdoo", |
|||
|
|||
'category': 'Contact', |
|||
'version': '1.0', |
|||
|
|||
'depends': ['base'], |
|||
|
|||
'data': [ |
|||
'views/res_partner.xml', |
|||
], |
|||
} |
@ -0,0 +1 @@ |
|||
import partner |
@ -0,0 +1,53 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from openerp import models, fields, api, _ |
|||
from openerp.exceptions import ValidationError |
|||
|
|||
def concat_names(*args): |
|||
""" |
|||
Concatenate only args that are not empty |
|||
@param args: a list of string |
|||
""" |
|||
return ' '.join(filter(bool, args)) |
|||
|
|||
class Partner(models.Model): |
|||
|
|||
_inherit = 'res.partner' |
|||
|
|||
firstname = fields.Char('First Name') |
|||
lastname = fields.Char('Last Name', required=True, default="/") |
|||
name = fields.Char(compute='_get_name', inverse='_set_name', store=True) |
|||
|
|||
@api.depends('firstname', 'lastname') |
|||
def _get_name(self): |
|||
for rec in self: |
|||
rec.name = concat_names(rec.firstname, rec.lastname) |
|||
|
|||
def _set_name(self): |
|||
""" |
|||
This allow to handle the case of code that write directly on the name at creation |
|||
Should never happen but in case it happen write on the lastname |
|||
If there is no firstname lastname and name are the same |
|||
""" |
|||
for rec in self: |
|||
if not rec.firstname: |
|||
rec.lastname = rec.name |
|||
|
|||
|
|||
def _compatibility_layer(self, vals): |
|||
if 'last_name' in vals: |
|||
if not 'lastname' in vals: |
|||
vals['lastname'] = vals['last_name'] |
|||
vals.pop('last_name') |
|||
if 'first_name' in vals: |
|||
if not 'firstname' in vals: |
|||
vals['firstname'] = vals['first_name'] |
|||
vals.pop('first_name') |
|||
return vals |
|||
|
|||
@api.multi |
|||
def write(self, vals): |
|||
return super(Partner, self).write(self._compatibility_layer(vals)) |
|||
|
|||
@api.model |
|||
def create(self, vals): |
|||
return super(Partner, self).create(self._compatibility_layer(vals)) |
@ -0,0 +1,17 @@ |
|||
<odoo> |
|||
<record model="ir.ui.view" id="beesdoo_partner_name_form_view"> |
|||
<field name="name">beesdoo.partner.form.view</field> |
|||
<field name="model">res.partner</field> |
|||
<field name="inherit_id" ref="point_of_sale.view_partner_property_form" /> |
|||
<field name="arch" type="xml"> |
|||
<field name="name" position="replace"> |
|||
<field name="name" class="oe_read_only" /> |
|||
<field name="firstname" placeholder="First Name" |
|||
class="oe_edit_only" |
|||
attrs="{'invisible' : [('company_type', '=', 'company')]}" /> |
|||
<field name="lastname" placeholder="Last Name" |
|||
class="oe_edit_only" default_focus="1" /> |
|||
</field> |
|||
</field> |
|||
</record> |
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue