[IMP] fix website_hr_recruitment, website_event, and create contact qweb widget
bzr revid: chm@openerp.com-20131206133003-to4lbgoynvviifq5
This commit is contained in:
parent
ef8322273e
commit
d0b813a016
|
@ -21,6 +21,7 @@ from lxml import etree, html
|
|||
from PIL import Image as I
|
||||
import openerp.modules
|
||||
|
||||
import openerp
|
||||
from openerp.osv import orm, fields
|
||||
from openerp.tools import ustr, DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
|
||||
from openerp.addons.web.http import request
|
||||
|
@ -197,6 +198,7 @@ class ManyToOne(orm.AbstractModel):
|
|||
matches = self.pool[column._obj].name_search(
|
||||
cr, uid, name=element.text_content().strip(), context=context)
|
||||
# FIXME: no match? More than 1 match?
|
||||
print element.text_content().strip()
|
||||
assert len(matches) == 1
|
||||
return matches[0][0]
|
||||
|
||||
|
@ -349,3 +351,43 @@ class RelativeDatetime(orm.AbstractModel):
|
|||
]
|
||||
|
||||
# get formatting from ir.qweb.field.relative but edition/save from datetime
|
||||
|
||||
|
||||
class Contact(orm.AbstractModel):
|
||||
_name = 'website.qweb.field.contact'
|
||||
_inherit = ['website.qweb.field', 'website.qweb.field.many2one']
|
||||
|
||||
def from_html(self, cr, uid, model, column, element, context=None):
|
||||
# FIXME: this behavior is really weird, what if the user wanted to edit the name of the related thingy? Should m2os really be editable without a widget?
|
||||
divs = element.xpath(".//div")
|
||||
for div in divs:
|
||||
if div != divs[0]:
|
||||
div.getparent().remove(div)
|
||||
return super(Contact, self).from_html(cr, uid, model, column, element, context=context)
|
||||
|
||||
def record_to_html(self, cr, uid, field_name, record, column, options=None, context=None):
|
||||
opf = options.get('fields') or ["name", "address", "phone", "mobile", "fax", "email"]
|
||||
|
||||
if not getattr(record, field_name):
|
||||
return None
|
||||
|
||||
id = getattr(record, field_name).id
|
||||
field_browse = self.pool[column._obj].browse(cr, openerp.SUPERUSER_ID, id, context={"show_address": True})
|
||||
value = werkzeug.utils.escape( field_browse.name_get()[0][1] )
|
||||
|
||||
IMD = self.pool["ir.model.data"]
|
||||
model, id = IMD.get_object_reference(cr, uid, "website", "contact")
|
||||
view = self.pool["ir.ui.view"].browse(cr, uid, id, context=context)
|
||||
|
||||
html = view.render({
|
||||
'name': value.split("\n")[0],
|
||||
'address': werkzeug.utils.escape("\n".join(value.split("\n")[1:])),
|
||||
'phone': field_browse.phone,
|
||||
'mobile': field_browse.mobile,
|
||||
'fax': field_browse.fax,
|
||||
'email': field_browse.email,
|
||||
'fields': opf,
|
||||
'options': options
|
||||
}, engine='website.qweb', context=context)
|
||||
|
||||
return html
|
||||
|
|
|
@ -496,3 +496,10 @@ table.well tr td {
|
|||
.oe_demo div a {
|
||||
color: white;
|
||||
}
|
||||
|
||||
address .fa.fa-mobile-phone {
|
||||
margin: 0 3px 0 2px;
|
||||
}
|
||||
address .fa.fa-file-text-o {
|
||||
margin-right: 1px;
|
||||
}
|
||||
|
|
|
@ -372,3 +372,9 @@ table.well tr
|
|||
font-weight: bold
|
||||
a
|
||||
color: white
|
||||
|
||||
address
|
||||
.fa.fa-mobile-phone
|
||||
margin: 0 3px 0 2px
|
||||
.fa.fa-file-text-o
|
||||
margin-right: 1px
|
||||
|
|
|
@ -686,5 +686,20 @@ Sitemap: <t t-esc="url_root"/>sitemap.xml
|
|||
</t>
|
||||
</template>
|
||||
|
||||
<template id="contact">
|
||||
<address t-ignore="true">
|
||||
<div t-att-class='"" if "name" in fields else "css_non_editable_mode_hidden"'><span t-esc="name"/></div>
|
||||
<div class='css_editable_mode_hidden'>
|
||||
<div t-if="address and 'address' in fields">
|
||||
<i class='fa fa-map-marker'/>
|
||||
<span t-raw="address.replace('\n', options.get('no_tag_br') and ', ' or '<br/> &nbsp; &nbsp; ')"/>
|
||||
</div>
|
||||
<div t-if="phone and 'phone' in fields"><i class='fa fa-phone'/> <span t-esc="phone"/></div>
|
||||
<div t-if="mobile and 'mobile' in fields"><i class='fa fa-mobile-phone'/> <span t-esc="mobile"/></div>
|
||||
<div t-if="fax and 'fax' in fields"><i class='fa fa-file-text-o'/> <span t-esc="fax"/></div>
|
||||
<div t-if="email and 'email' in fields"><i class='fa fa-envelope'/> <span t-esc="email"/></div>
|
||||
</div>
|
||||
</address>
|
||||
</template>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -336,19 +336,10 @@
|
|||
<a t-att-href="event.google_map_link()" target="_BLANK">
|
||||
<img t-att-src="event.google_map_img()" width="100%%"/>
|
||||
</a>
|
||||
<address class="mt16 mb8" t-field="event.address_id"> <!-- TODO: use widget contact -->
|
||||
<!-- <strong t-field="event.address_id"/>
|
||||
<p t-field="event.address_id"/>
|
||||
<div t-if="event.address_id.phone">
|
||||
<span class="fa fa-phone"/> <span t-field="event.address_id.phone"/>
|
||||
</div>
|
||||
<div t-if="event.address_id.email">
|
||||
<span class="fa fa-envelope"/>
|
||||
<a t-att-href="'mailto:'+event.address_id.email">
|
||||
<span t-field="event.address_id.email"/>
|
||||
</a>
|
||||
</div> -->
|
||||
</address>
|
||||
<div class="mt16 mb8" t-field="event.address_id" t-field-options='{
|
||||
"widget": "contact",
|
||||
"fields": ["address", "phone", "mobile", "fax", "email"]
|
||||
}'/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -366,15 +357,10 @@
|
|||
<div class="panel-heading">
|
||||
<h4>Organizer</h4>
|
||||
</div>
|
||||
<div class="panel-body" t-field="event.organizer_id"> <!-- TODO: use widget contact -->
|
||||
<!-- <p><strong t-field="event.organizer_id.display_name"/></p>
|
||||
<div t-if="event.phone">
|
||||
<span class="fa fa-phone"/> <span t-field="event.phone"/>
|
||||
</div>
|
||||
<div t-if="event.email">
|
||||
<i class="fa fa-envelope"/> <span t-field="event.email"/>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="panel-body" t-field="event.organizer_id" t-field-options='{
|
||||
"widget": "contact",
|
||||
"fields": ["name", "phone", "mobile", "fax", "email"]
|
||||
}'/>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
|
|
|
@ -17,7 +17,11 @@ class website_hr_recruitment(http.Controller):
|
|||
'/jobs/office/<model("res.partner"):office>'
|
||||
], type='http', auth="public", multilang=True)
|
||||
def jobs(self, department=None, office=None):
|
||||
jobs = self._browse_jobs([])
|
||||
JobsObj = request.registry['hr.job']
|
||||
jobpost_ids = JobsObj.search(request.cr, request.uid, [],
|
||||
order="website_published desc,no_of_recruitment desc",
|
||||
context=request.context)
|
||||
jobs = JobsObj.browse(request.cr, request.uid, jobpost_ids, context=dict(request.context, show_address=True, no_tag_br=True))
|
||||
|
||||
departments = set()
|
||||
offices = set()
|
||||
|
@ -28,12 +32,12 @@ class website_hr_recruitment(http.Controller):
|
|||
offices.add(job.address_id)
|
||||
|
||||
if department or office:
|
||||
domain = []
|
||||
if department:
|
||||
domain.append(('department_id','=', department.id))
|
||||
if office:
|
||||
domain.append(('address_id','=', office.id))
|
||||
jobs = self._browse_jobs(domain)
|
||||
_jobs = []
|
||||
for job in jobs:
|
||||
if (department and job.department_id.id == department.id) or \
|
||||
(office and job.address_id.id == office.id):
|
||||
_jobs.add(job)
|
||||
jobs = _jobs
|
||||
|
||||
return request.website.render("website_hr_recruitment.index", {
|
||||
'jobs': jobs,
|
||||
|
@ -97,11 +101,3 @@ class website_hr_recruitment(http.Controller):
|
|||
}, context=request.context)
|
||||
|
||||
return request.redirect("/job/detail/%s/?enable_editor=1" % job_id)
|
||||
|
||||
def _browse_jobs(self, domain):
|
||||
Jobs = request.registry['hr.job']
|
||||
jobpost_ids = Jobs.search(request.cr, request.uid, domain,
|
||||
order="website_published desc,no_of_recruitment desc",
|
||||
context=request.context)
|
||||
jobs = Jobs.browse(request.cr, request.uid, jobpost_ids, context=request.context)
|
||||
return jobs
|
||||
|
|
|
@ -67,13 +67,12 @@
|
|||
</small>
|
||||
</h3>
|
||||
|
||||
<div t-if="job.address_id">
|
||||
<i class="fa fa-map-marker"/>
|
||||
<span t-field="job.address_id.city"/>
|
||||
<span t-if="job.address_id.state_id" t-field="job.address_id.state_id"/>
|
||||
, <span t-field="job.address_id.country_id.name"/>
|
||||
<span t-if="not job.website_published" class="label label-danger">not published</span>
|
||||
</div>
|
||||
<span t-field="job.address_id" t-field-options='{
|
||||
"widget": "contact",
|
||||
"fields": ["address"],
|
||||
"no_tag_br": true
|
||||
}'/>
|
||||
<span t-if="not job.website_published" class="label label-danger">not published</span>
|
||||
<div class="text-muted">
|
||||
<i class="fa fa-clock-o"/> <span t-field="job.write_date"/>
|
||||
</div>
|
||||
|
@ -112,9 +111,11 @@
|
|||
|
||||
<div class="oe_structure" style="clear:both;">
|
||||
<h1 class="text-center" t-field="job.name"/>
|
||||
<h5 class="text-center">
|
||||
<i class="fa fa-map-marker"/> <span t-field="job.address_id.city"/> <span t-if="job.address_id.state_id" t-field="job.address_id.state_id.name"/>, <span t-field="job.address_id.country_id.name"/>
|
||||
</h5>
|
||||
<h5 class="text-center" t-field="job.address_id" t-field-options='{
|
||||
"widget": "contact",
|
||||
"fields": ["address"],
|
||||
"no_tag_br": true
|
||||
}'/>
|
||||
<h5 class="text-center text-muted">
|
||||
<i class="fa fa-clock-o"/> <span t-field="job.write_date"/>
|
||||
</h5>
|
||||
|
|
Loading…
Reference in New Issue