Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.0][Issue] Odoo store function: JSON not serializable #4628

Closed
alca259 opened this issue Jan 10, 2015 · 3 comments
Closed

[8.0][Issue] Odoo store function: JSON not serializable #4628

alca259 opened this issue Jan 10, 2015 · 3 comments

Comments

@alca259
Copy link

alca259 commented Jan 10, 2015

Hello, i have problems with update stored data. It's works but later i cannot see it... It say this when i try to view.

Odoo Server Error
Traceback (most recent call last):
File "D:\Desarrollo\Odoo\Server\server.\openerp\http.py", line 517, in handle_exception
File "D:\Desarrollo\Odoo\Server\server.\openerp\http.py", line 539, in dispatch
File "D:\Desarrollo\Odoo\Server\server.\openerp\http.py", line 506, in json_response
File "simplejson__init
.pyc", line 354, in dumps
File "simplejson\encoder.pyc", line 264, in encode
File "simplejson\encoder.pyc", line 612, in _iterencode
File "simplejson\encoder.pyc", line 568, in _iterencode_dict
File "simplejson\encoder.pyc", line 568, in _iterencode_dict
File "simplejson\encoder.pyc", line 568, in _iterencode_dict
File "simplejson\encoder.pyc", line 568, in _iterencode_dict
File "simplejson\encoder.pyc", line 455, in _iterencode_list
File "simplejson\encoder.pyc", line 622, in _iterencode
File "simplejson\encoder.pyc", line 239, in default
TypeError: <function _get_lines at 0x0603C7F0> is not JSON serializable

This is my code

from openerp import models, fields, api, _, exceptions
class account_analytic_account(models.Model):

    _inherit = 'account.analytic.account'

    @api.one
    @api.multi
    @api.depends('planned_resources_ids')
    def _get_horas_planificadas(self):
        """
        Calcula horas planificadas
        """
        data = 0.0

        # Recorremos los datos obtenidos
        for plan_line in self.planned_resources_ids:
            if plan_line:
                data += plan_line.plan_coste_esf_tot

        self.planned_hours = data

    @api.multi
    def _get_lines(self):
        result = {}
        for line in self.planned_resources_ids:
            result[line.id] = True
        return result.keys()

    #Properties
    planned_resources_ids = fields.One2many('planned.resources.contract', 'contract_id', _(u'Líneas de contrato'))
    planned_hours = fields.Float(compute = "_get_horas_planificadas", string = _(u'Total horas planificadas'), digits = (12, 2), store = { 
        'account.analytic.account': (_get_lines, ['planned_resources_ids'], 10)
    })
@alca259 alca259 changed the title [Issue]Odoo store function: JSON not serializable [8.0][Issue] Odoo store function: JSON not serializable Jan 10, 2015
@npiganeau
Copy link
Contributor

  1. This sort of questions should be asked on the Q&A of Odoo website and not here. Indeed, it is not a bug report.
  2. store parameter in new api is a boolean, not a dict anymore (see https://www.odoo.com/documentation/8.0/reference/orm.html#fields)
  3. api.one and api.multi are mutually exclusive: self is either a record or a recordset, not both.

@xmo-odoo
Copy link
Collaborator

@npiganeau seems to have covered all the bases, closing

@LeartS
Copy link
Contributor

LeartS commented Jan 12, 2015

@xmo-odoo you think it would be possible to add labels for closed issues like "invalid", "fixed", "duplicate"? That way we could take a look at the closed issues to see problems recently resolved without having to go through the invalid issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants