Browse Source

[IMP] change view presentation of passport

pull/2/head
EL HADJI DEM 11 years ago
parent
commit
185e9aaea2
  1. 15
      passport/res_passport.py
  2. 12
      passport/res_passport_view.xml
  3. 38
      passport_partner/i18n/fr.po
  4. 36
      passport_partner/i18n/passport_partner.pot
  5. 28
      passport_partner/res_partner.py
  6. 42
      passport_partner/res_partner_view.xml

15
passport/res_passport.py

@ -42,4 +42,19 @@ class res_passport(orm.Model):
help="Gender."), help="Gender."),
} }
def name_get(self, cr, uid, ids, context=None):
if context is None:
context = {}
if isinstance(ids, (int, long)):
ids = [ids]
res = []
reads = self.read(cr, uid, ids, ['name', 'country_id'], context)
for record in reads:
name = record['name']
if record['country_id']:
name = record['country_id'][1] + ' | ' + name
res.append((record['id'], name))
return res
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

12
passport/res_passport_view.xml

@ -26,12 +26,12 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="PassportForm" version="7.0" > <form string="PassportForm" version="7.0" >
<group col="4"> <group col="4">
<field name="name" string="Owner name (As printed into the passport)"/>
<field name="number"/>
<field name="country_id"/>
<field name="expiration_date"/>
<field name="birth_date"/>
<field name="gender"/>
<field name="country_id"/>
<field name="name" string="Owner name (As printed into the passport)"/>
<field name="number"/>
<field name="gender"/>
<field name="expiration_date"/>
<field name="birth_date"/>
</group> </group>
</form> </form>
</field> </field>

38
passport_partner/i18n/fr.po

@ -6,8 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n" "Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-01-17 16:33+0000\n"
"PO-Revision-Date: 2014-01-17 11:34-0500\n"
"POT-Creation-Date: 2014-02-05 22:07+0000\n"
"PO-Revision-Date: 2014-02-05 17:09-0500\n"
"Last-Translator: EL Hadji DEM <elhadji.dem@savoirfairelinux.com>\n" "Last-Translator: EL Hadji DEM <elhadji.dem@savoirfairelinux.com>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -16,26 +16,54 @@ msgstr ""
"Plural-Forms: \n" "Plural-Forms: \n"
"X-Generator: Poedit 1.5.4\n" "X-Generator: Poedit 1.5.4\n"
#. module: passport_partner
#: view:res.partner:0
msgid "Create"
msgstr "Créer"
#. module: passport_partner #. module: passport_partner
#: view:res.partner:0 #: view:res.partner:0
msgid "Passport Details" msgid "Passport Details"
msgstr "Détails du passeport" msgstr "Détails du passeport"
#. module: passport_partner
#: view:res.passport:0
msgid "or"
msgstr "ou"
#. module: passport_partner
#: code:addons/passport_partner/res_partner.py:37
#: code:addons/passport_partner/res_partner.py:38
#, python-format
msgid "New Passport"
msgstr "Nouveau passeport"
#. module: passport_partner
#: view:res.passport:0
msgid "Save and Close"
msgstr "Enregistrer et fermer"
#. module: passport_partner #. module: passport_partner
#: field:res.passport,partner_id:0 #: field:res.passport,partner_id:0
msgid "Contact" msgid "Contact"
msgstr "Contact" msgstr "Contact"
#. module: passport_partner #. module: passport_partner
#: model:ir.actions.act_window,name:passport_partner.action_passport_list
#: model:ir.model,name:passport_partner.model_res_passport view:res.partner:0 #: model:ir.model,name:passport_partner.model_res_passport view:res.partner:0
#: field:res.partner,passport_ids:0
#: field:res.partner,passport_ids:0 view:res.passport:0
msgid "Passport" msgid "Passport"
msgstr "Passeport" msgstr "Passeport"
#. module: passport_partner #. module: passport_partner
#: model:ir.model,name:passport_partner.model_res_partner #: model:ir.model,name:passport_partner.model_res_partner
msgid "Partner" msgid "Partner"
msgstr "Partenaire"
msgstr "Organisme"
#. module: passport_partner
#: view:res.passport:0
msgid "Discard"
msgstr "Annuler"
#. module: passport_partner #. module: passport_partner
#: help:res.passport,partner_id:0 #: help:res.passport,partner_id:0
@ -43,6 +71,6 @@ msgid "Contact."
msgstr "Contact." msgstr "Contact."
#. module: passport_partner #. module: passport_partner
#: view:res.partner:0
#: view:res.partner:0 view:res.passport:0
msgid "Owner name (As printed into the passport)" msgid "Owner name (As printed into the passport)"
msgstr "Nom du propriétaire (Comme écrit sur le passeport)" msgstr "Nom du propriétaire (Comme écrit sur le passeport)"

36
passport_partner/i18n/passport_partner.pot

@ -6,8 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n" "Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-01-17 16:32+0000\n"
"PO-Revision-Date: 2014-01-17 11:32-0500\n"
"POT-Creation-Date: 2014-02-05 22:05+0000\n"
"PO-Revision-Date: 2014-02-05 17:06-0500\n"
"Last-Translator: EL Hadji DEM <elhadji.dem@savoirfairelinux.com>\n" "Last-Translator: EL Hadji DEM <elhadji.dem@savoirfairelinux.com>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -16,19 +16,42 @@ msgstr ""
"Plural-Forms: \n" "Plural-Forms: \n"
"X-Generator: Poedit 1.5.4\n" "X-Generator: Poedit 1.5.4\n"
#. module: passport_partner
#: view:res.partner:0
msgid "Create"
msgstr ""
#. module: passport_partner #. module: passport_partner
#: view:res.partner:0 #: view:res.partner:0
msgid "Passport Details" msgid "Passport Details"
msgstr "" msgstr ""
#. module: passport_partner
#: view:res.passport:0
msgid "or"
msgstr ""
#. module: passport_partner
#: code:addons/passport_partner/res_partner.py:37
#: code:addons/passport_partner/res_partner.py:38
#, python-format
msgid "New Passport"
msgstr ""
#. module: passport_partner
#: view:res.passport:0
msgid "Save and Close"
msgstr ""
#. module: passport_partner #. module: passport_partner
#: field:res.passport,partner_id:0 #: field:res.passport,partner_id:0
msgid "Contact" msgid "Contact"
msgstr "" msgstr ""
#. module: passport_partner #. module: passport_partner
#: model:ir.actions.act_window,name:passport_partner.action_passport_list
#: model:ir.model,name:passport_partner.model_res_passport view:res.partner:0 #: model:ir.model,name:passport_partner.model_res_passport view:res.partner:0
#: field:res.partner,passport_ids:0
#: field:res.partner,passport_ids:0 view:res.passport:0
msgid "Passport" msgid "Passport"
msgstr "" msgstr ""
@ -37,12 +60,17 @@ msgstr ""
msgid "Partner" msgid "Partner"
msgstr "" msgstr ""
#. module: passport_partner
#: view:res.passport:0
msgid "Discard"
msgstr ""
#. module: passport_partner #. module: passport_partner
#: help:res.passport,partner_id:0 #: help:res.passport,partner_id:0
msgid "Contact." msgid "Contact."
msgstr "" msgstr ""
#. module: passport_partner #. module: passport_partner
#: view:res.partner:0
#: view:res.partner:0 view:res.passport:0
msgid "Owner name (As printed into the passport)" msgid "Owner name (As printed into the passport)"
msgstr "" msgstr ""

28
passport_partner/res_partner.py

@ -21,6 +21,7 @@
############################################################################## ##############################################################################
from openerp.osv import orm, fields from openerp.osv import orm, fields
from openerp.tools.translate import _
class res_partner(orm.Model): class res_partner(orm.Model):
@ -29,4 +30,31 @@ class res_partner(orm.Model):
'passport_ids': fields.one2many('res.passport', 'partner_id', 'Passport'), 'passport_ids': fields.one2many('res.passport', 'partner_id', 'Passport'),
} }
def action_add_passport_form_view(self, cr, uid, ids, context=None):
"""Call action, if there is a contact, put it in the name."""
ir_model_data = self.pool.get('ir.model.data')
contacts = self.browse(cr, uid, ids, context=context)
contact_name = ('%s : %s ' % (contacts[0].full_name, _('New Passport')) if len(contacts) == 1 else False)
name = contact_name or _('New Passport')
try:
compose_form_id = ir_model_data.get_object_reference(cr, uid, 'passport_partner', 'add_passport_form_view')[1]
except ValueError:
compose_form_id = False
ctx = dict(context)
ctx.update({
'default_res_id': ids[0],
'default_partner_id': ids[0],
})
return {
'name': name,
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'res.passport',
'views': [(compose_form_id, 'form')],
'view_id': compose_form_id,
'target': 'new',
'context': ctx,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

42
passport_partner/res_partner_view.xml

@ -8,28 +8,42 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<notebook position="inside"> <notebook position="inside">
<page string="Passport" attrs="{'invisible': ['|','|',('is_company','=',True),('contact_id','!=',False)]}"> <page string="Passport" attrs="{'invisible': ['|','|',('is_company','=',True),('contact_id','!=',False)]}">
<button string="Create" name="action_add_passport_form_view" type="object" class="oe_highlight"/>
<field name="passport_ids" nolabel="1"> <field name="passport_ids" nolabel="1">
<tree string="Passport Details">
<field name="name"/>
<field name="number"/>
<tree string="Passport Details" create="false" version="7.0">
<field name="country_id"/> <field name="country_id"/>
<field name="number"/>
<field name="expiration_date"/> <field name="expiration_date"/>
<field name="name"/>
</tree> </tree>
<form string="Passport" version="7.0">
<group col="4">
<field name="name" string="Owner name (As printed into the passport)"/>
<field name="number"/>
<field name="country_id"/>
<field name="expiration_date"/>
<field name="birth_date"/>
<field name="gender"/>
<field name="partner_id" invisible="1"/>
</group>
</form>
</field> </field>
</page> </page>
</notebook> </notebook>
</field> </field>
</record> </record>
<!-- Form Views passport-contact-->
<record model="ir.ui.view" id="add_passport_form_view">
<field name="name">Passport Form View</field>
<field name="model">res.passport</field>
<field name="arch" type="xml">
<form string="Passport" version="7.0">
<group col="4">
<field name="country_id"/>
<field name="name" string="Owner name (As printed into the passport)"/>
<field name="number"/>
<field name="gender"/>
<field name="expiration_date"/>
<field name="birth_date"/>
<field name="partner_id" invisible="1"/>
</group>
<footer attrs="{'invisible': [('partner_id','=',False)]}">
<button string="Save and Close" name="_" type="action" class="oe_highlight" accesskey="C"/>
or
<button string="Discard" class="oe_link" special="cancel" accesskey="D"/>
</footer>
</form>
</field>
</record>
</data> </data>
</openerp> </openerp>
Loading…
Cancel
Save