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
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]
]
# 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
.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;
+}
font-weight: bold
a
color: white
+
+address
+ .fa.fa-mobile-phone
+ margin: 0 3px 0 2px
+ .fa.fa-file-text-o
+ margin-right: 1px
</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>
<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>
<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">
'/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()
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,
}, 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
</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>
<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>