Community mailing list archives

community@mail.odoo.com

Re: Problem extending state

by Anders Wallenquist <anders.wallenquist@kreawit.se> - 08/27/2014 08:03:03
Den 2014-08-27 13:44, Anders Wallenquist skrev:
<blockquote cite="mid:53FDC35C.7050505@kreawit.se" type="cite">
Den 2014-08-27 12:49, Kalpana Hemnani skrev:
<blockquote cite="mid:CAPu0Cpf2ZmJqCohMONF2U+WM4nZdS0QzfxAVuVRX52Wo2DdRpA@mail.gmail.com" type="cite">
Hello Anders,

Put field name(instead of field string) as {'state': 'submitted'} instead {'status': 'submitted'}.

Yes this is how the code looks like now:

    def invoice_submitted(self, cr, uid, ids, context=None,):
        for inv in self.browse(cr, uid, ids, context=context):
            self.pool.get('account.invoice').write(cr, uid, [inv.id], {'state': 'submitted'})
        return True

I have greped after 'status' in other places too. Its was obvious wrong earlier, thank you.
But I still got the same error.



2014-08-27 11:20:30,188 27584 ERROR aw20 openerp.http: Exception during JSON request handling.
Traceback (most recent call last):
  File "/opt/odoo/odoo-server/openerp/http.py", line 476, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo/odoo-server/openerp/http.py", line 495, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoo/odoo-server/openerp/http.py", line 311, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/http.py", line 308, in checked_call
    return self.endpoint(*a, **kw)
  File "/opt/odoo/odoo-server/openerp/http.py", line 685, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo/odoo-server/openerp/http.py", line 360, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo/odoo-server/addons/web/controllers/main.py", line 952, in exec_workflow
    return request.session.exec_workflow(model, id, signal)
  File "/opt/odoo/odoo-server/openerp/http.py", line 988, in exec_workflow
    r = self.proxy('object').exec_workflow(self.db, self.uid, self.password, model, signal, id)
  File "/opt/odoo/odoo-server/openerp/http.py", line 759, in proxy_method
    result = dispatch_rpc(self.service_name, method, args)
  File "/opt/odoo/odoo-server/openerp/http.py", line 93, in dispatch_rpc
    result = dispatch(method, params)
  File "/opt/odoo/odoo-server/openerp/service/model.py", line 37, in dispatch
    res = fn(db, uid, *params)
  File "/opt/odoo/odoo-server/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/service/model.py", line 183, in exec_workflow
    return exec_workflow_cr(cr, uid, obj, signal, *args)
  File "/opt/odoo/odoo-server/openerp/service/model.py", line 177, in exec_workflow_cr
    return execute_cr(cr, uid, obj, 'signal_workflow', [res_id], signal)[res_id]
  File "/opt/odoo/odoo-server/openerp/service/model.py", line 159, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/opt/odoo/odoo-server/openerp/api.py", line 234, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/models.py", line 3457, in signal_workflow
    result[res_id] = workflow.trg_validate(uid, self._name, res_id, signal, cr)
  File "/opt/odoo/odoo-server/openerp/workflow/__init__.py", line 85, in trg_validate
    return WorkflowService.new(cr, uid, res_type, res_id).validate(signal)
  File "/opt/odoo/odoo-server/openerp/workflow/service.py", line 91, in validate
    res2 = wi.validate(signal)
  File "/opt/odoo/odoo-server/openerp/workflow/instance.py", line 75, in validate
    wi.process(signal=signal, force_running=force_running, stack=stack)
  File "/opt/odoo/odoo-server/openerp/workflow/workitem.py", line 120, in process
    ok = self._split_test(activity['split_mode'], signal, stack)
  File "/opt/odoo/odoo-server/openerp/workflow/workitem.py", line 248, in _split_test
    self._join_test(t[0], t[1], stack)
  File "/opt/odoo/odoo-server/openerp/workflow/workitem.py", line 257, in _join_test
    WorkflowItem.create(self.session, self.record, activity, inst_id, stack=stack)
  File "/opt/odoo/odoo-server/openerp/workflow/workitem.py", line 95, in create
    workflow_item.process(stack=stack)
  File "/opt/odoo/odoo-server/openerp/workflow/workitem.py", line 116, in process
    if not self._execute(activity, stack):
  File "/opt/odoo/odoo-server/openerp/workflow/workitem.py", line 162, in _execute
    returned_action = self.wkf_expr_execute(activity)
  File "/opt/odoo/odoo-server/openerp/workflow/workitem.py", line 313, in wkf_expr_execute
    return self.wkf_expr_eval_expr(activity['action'])
  File "/opt/odoo/odoo-server/openerp/workflow/workitem.py", line 291, in wkf_expr_eval_expr
    result = eval(line, env, nocopy=True)
  File "/opt/odoo/odoo-server/openerp/tools/safe_eval.py", line 312, in safe_eval
    return eval(c, globals_dict, locals_dict)
  File "", line 1, in <module>
  File "/opt/odoo/odoo-server/openerp/api.py", line 232, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/api.py", line 549, in new_api
    result = method(self._model, cr, uid, self.ids, *args, **kwargs)
  File "/opt/odoo/odoo-server/addons/mail/mail_thread.py", line 428, in write
    result = super(mail_thread, self).write(cr, uid, ids, values, context=context)
  File "/opt/odoo/odoo-server/openerp/api.py", line 234, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/api.py", line 357, in old_api
    result = method(recs, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/models.py", line 3635, in write
    self._write(old_vals)
  File "/opt/odoo/odoo-server/openerp/api.py", line 232, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/api.py", line 549, in new_api
    result = method(self._model, cr, uid, self.ids, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/models.py", line 3729, in _write
    self._check_selection_field_value(cr, user, field, vals[field], context=context)
  File "/opt/odoo/odoo-server/openerp/api.py", line 234, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/models.py", line 2265, in _check_selection_field_value
    _('The value "%s" for the field "%s.%s" is not in the selection') % (value, self._name, field))
except_orm: ('ValidateError', 'The value "submitted" for the field "account.invoice.state" is not in the selection')


<blockquote cite="mid:53FDC35C.7050505@kreawit.se" type="cite">
Hope this helps.
Thank you!

Your eyes are the first you get blind at ;-)

First error down. I still get the same error message...

Regards
Anders Wallenquist
<blockquote cite="mid:CAPu0Cpf2ZmJqCohMONF2U+WM4nZdS0QzfxAVuVRX52Wo2DdRpA@mail.gmail.com" type="cite">


On Wed, Aug 27, 2014 at 4:03 PM, Anders Wallenquist <aw@kreawit.se> wrote:
I'm trying to extend state in account.invoice.

class account_invoice(osv.osv):
     _inherit = "account.invoice"
     _columns = {
         'state': fields.selection([
             ('draft','Draft'),
             ('submitted','Submitted'),
             ('proforma','Pro-forma'),
             ('proforma2','Pro-forma'),
             ('open','Open'),
             ('paid','Paid'),
             ('cancel','Cancelled'),
             ],'Status', select=True, readonly=True, 
track_visibility='onchange',
             help=' * The \'Draft\' status is used when a user is 
encoding a new and unconfirmed Invoice. \
             \n* The \'Submitted\' when invoice is in submitted 
status,invoice does not have an invoice number and waits for approval. \
             \n* The \'Pro-forma\' when invoice is in Pro-forma 
status,invoice does not have an invoice number. \
             \n* The \'Open\' status is used when user create invoice,a 
invoice number is generated.Its in open status till user does not pay 
invoice. \
             \n* The \'Paid\' status is set automatically when the 
invoice is paid. Its related journal entries may or may not be reconciled. \
             \n* The \'Cancelled\' status is used when user cancel 
invoice.'),
     }

     def invoice_submitted(self, cr, uid, ids, context=None,):
         for inv in self.browse(cr, uid, ids, context=context):
             self.pool.get('account.invoice').write(cr, uid, [inv.id], 
{'status': 'submitted'})
         return True


__openerp__.py:
...
     'depends': ['account'],
...

__init__.py:
import account_invoice


I get this error message:

The value "submitted" for the field "account.invoice.state" is not in 
the selection


What is my wrong doing?

Regards
Anders Wallenquist

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe




--
Thank You,
Regards,
Kalpana Hemnani
Software Engineer

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe