Skip to content
Snippets Groups Projects
Commit bd4d1dc13ff0 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

3.6 api update

parent 5edfac9f2469
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@
@property
def workcase(self):
rql = 'Any R WHERE E has_lines EL, EL eid %(el)s, E spent_for W, W ref R'
rset = self.req.execute(rql, {'el': self.eid})
rset = self._cw.execute(rql, {'el': self.eid}, 'el')
if rset:
return rset[0][0]
return None
"""template-specific forms/views/actions/components"""
from logilab.common.decorators import monkeypatch
from cubicweb.web import uicfg
from cubicweb.web.formwidgets import RestrictedAutoCompletionWidget
from cubicweb.web import uicfg, formwidgets as fw
from cubicweb.web.views import basecontrollers
_afs = uicfg.autoform_section
......@@ -6,5 +5,4 @@
from cubicweb.web.views import basecontrollers
_afs = uicfg.autoform_section
_afs.tag_subject_of(('Expense', 'spent_for', '*'), 'primary')
_affk = uicfg.autoform_field_kwargs
......@@ -10,2 +8,4 @@
_affk = uicfg.autoform_field_kwargs
_afs.tag_subject_of(('Expense', 'spent_for', '*'), 'main', 'attributes')
_afs.tag_subject_of(('Expense', 'spent_for', '*'), 'muledit', 'attributes')
_affk.tag_subject_of(('Expense', 'spent_for', '*'),
......@@ -11,7 +11,7 @@
_affk.tag_subject_of(('Expense', 'spent_for', '*'),
{'widget': RestrictedAutoCompletionWidget(autocomplete_initfunc='get_concerned_by')})
{'widget': fw.RestrictedAutoCompletionWidget(autocomplete_initfunc='get_concerned_by')})
@monkeypatch(basecontrollers.JSonController)
@basecontrollers.jsonize
def js_get_concerned_by(self):
......@@ -13,6 +13,6 @@
@monkeypatch(basecontrollers.JSonController)
@basecontrollers.jsonize
def js_get_concerned_by(self):
return self.req.execute('DISTINCT Any W,R ORDERBY R WHERE W ref R').rows
return self._cw.execute('DISTINCT Any W,R ORDERBY R WHERE W ref R').rows
......@@ -7,10 +7,10 @@
__docformat__ = "restructuredtext en"
from logilab.mtconverter import html_escape
from logilab.mtconverter import xml_escape
from cubicweb.selectors import implements
from cubicweb.view import EntityView
class ExpenseAccountingXmlView(EntityView):
......@@ -11,10 +11,10 @@
from cubicweb.selectors import implements
from cubicweb.view import EntityView
class ExpenseAccountingXmlView(EntityView):
id = 'accexpense'
__regid__ = 'accexpense'
__select__ = implements('Expense')
title = _('accounting entry view')
......@@ -22,8 +22,8 @@
content_type = 'text/xml'
def cell_call(self, row, col):
entity = self.entity(row, col)
entity = self.cw_rset.get_entity(row, col)
self.wview('accentry', entity.related('has_lines'))
class ExpenseLineAccountingEntryXmlView(EntityView):
......@@ -26,8 +26,8 @@
self.wview('accentry', entity.related('has_lines'))
class ExpenseLineAccountingEntryXmlView(EntityView):
id = 'accentry'
__regid__ = 'accentry'
__select__ = implements('ExpenseLine',)
title = _('accounting entry view')
......@@ -37,5 +37,5 @@
def call(self):
"""display a list of entities by calling their <item_vid> view
"""
self.w(u'<?xml version="1.0" encoding="%s"?>\n' % self.req.encoding)
self.w(u'<?xml version="1.0" encoding="%s"?>\n' % self._cw.encoding)
self.w(u'<ecritures>\n')
......@@ -41,6 +41,6 @@
self.w(u'<ecritures>\n')
for i in xrange(self.rset.rowcount):
for i in xrange(self.cw_rset.rowcount):
self.cell_call(i, 0)
self.w(u'</ecritures>\n')
def cell_call(self, row, col):
......@@ -43,6 +43,6 @@
self.cell_call(i, 0)
self.w(u'</ecritures>\n')
def cell_call(self, row, col):
entity = self.complete_entity(row, col)
entity = self.cw_rset.complete_entity(row, col)
self.w(u' <ecriture date="%s">\n' % entity.diem.strftime('%Y-%m-%d'))
......@@ -48,5 +48,5 @@
self.w(u' <ecriture date="%s">\n' % entity.diem.strftime('%Y-%m-%d'))
self.w(u' <libelle>%s</libelle>\n' % html_escape(entity.dc_long_title()))
self.w(u' <libelle>%s</libelle>\n' % xml_escape(entity.dc_long_title()))
amount = round(entity.euro_amount(), 2)
taxes = round(entity.taxes, 2)
self.w(u' <credit compte="%s" montant="%.2f" />\n' % (
......
......@@ -10,8 +10,8 @@
from cubicweb.web.action import Action
class AccountingAction(Action):
id = 'accaction'
__regid__ = 'accaction'
__select__ = implements('Expense')
title = _('generate accounting entries')
def url(self):
......@@ -14,7 +14,7 @@
__select__ = implements('Expense')
title = _('generate accounting entries')
def url(self):
entity = self.entity(0, 0)
entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
return entity.absolute_url(vid='accexpense')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment