i want to insert a new button 'Approval' as well as it's state 'Approval' in purchase order ,
but i don't know how to customize current state in purchase_view.xml
<field name="state" widget="statusbar" statusbar_visible="draft,sent,bid,approved,done" statusbar_colors='{"except_picking":"red","except_invoice":"red","confirmed":"blue"}' readonly="1"/>
to :
<field name="state" widget="statusbar" statusbar_visible="draft,sent,bid,approval,approved,done" statusbar_colors='{"except_picking":"red","except_invoice":"red","confirmed":"blue"}' readonly="1"/>
then when i hit Approval button i want to insert the current user login in my custom one2many column
here's the code :
approval_view.xml
<button name="view_picking" position="after">
<button name="wtc_approval" state="Approval" string="Approval" type="object" class="oe_highlight"/>
</button>
approval.py
def wtc_approval(self, cr, uid, ids, context=None):
todo = []
for approval in self.browse(cr, uid, ids, context=context):
if not approval.app_line:
raise osv.except_osv(_('Error!'),_('Kolom approval belum terisi'))
for x in approval.app_line:
todo.insert([1, 5,{'pelaksana':x.pelaksana}])
self.pool.get('wtc.approval.line').action_confirm(cr, uid, todo, context)
for id in ids:
self.write(cr, uid, [id], {'state' : 'approval', 'validator' : uid})
return True
thanks in advance ,,
Traceback (most recent call last): File "/home/ajeng/odoo/openerp-8.0/openerp/http.py", line 499, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/home/ajeng/odoo/openerp-8.0/openerp/http.py", line 516, in dispatch result = self._call_function(**self.params) File "/home/ajeng/odoo/openerp-8.0/openerp/http.py", line 282, in _call_function return checked_call(self.db, *args, **kwargs) File "/home/ajeng/odoo/openerp-8.0/openerp/service/model.py", line 113, in wrapper return f(dbname, *args, **kwargs) File "/home/ajeng/odoo/openerp-8.0/openerp/http.py", line 279, in checked_call return self.endpoint(*a, **kw) File "/home/ajeng/odoo/openerp-8.0/openerp/http.py", line 732, in __call__ return self.method(*args, **kw) File "/home/ajeng/odoo/openerp-8.0/openerp/http.py", line 375, in response_wrap response = f(*args, **kw) File "/home/ajeng/odoo/addons/HONDA/web/controllers/main.py", line 948, in call_button action = self._call_kw(model, method, args, {}) File "/home/ajeng/odoo/addons/HONDA/web/controllers/main.py", line 936, in _call_kw return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs) File "/home/ajeng/odoo/openerp-8.0/openerp/api.py", line 237, in wrapper return old_api(self, *args, **kwargs) File "/home/ajeng/odoo/addons/HONDA/wtc_approval/approval.py", line 32, in wtc_approval todo.insert([1, 5,5,{'pelaksana':x.pelaksana}]) TypeError: insert() takes exactly 2 arguments (1 given)
@Ajeng.. Can you provided the definition of "insert" method?
i want to insert new list in current state but i don't know the code