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][regression] Problem with computed integer fields #3972

Closed
ludwiktrammer opened this issue Dec 1, 2014 · 2 comments
Closed

[8.0][regression] Problem with computed integer fields #3972

ludwiktrammer opened this issue Dec 1, 2014 · 2 comments
Assignees

Comments

@ludwiktrammer
Copy link
Contributor

An regression exists introduced in commit f2e4a10 (on November 3th).

I've got a model with a computed integer field:

class Foo(models.Model):
    _name = 'my.foo'

    # ...
    age = fields.Integer(compute='compute_age')

    @api.one
    def compute_age(self):
        self.age = 25  # simplified example ;)

When I try to display objects of this model in kanban view (grouped by an entirely different field) I get the following error:

File "/[snip]/odoo/openerp/models.py", line 2101, in read_group
    if getattr(self._fields[f].base_field.column, '_classic_write')
AttributeError: 'NoneType' object has no attribute '_classic_write'

The problem didn't exist before commit f2e4a10. It seems that this is the change that causes the problem.

@yvaucher
Copy link
Contributor

yvaucher commented Dec 3, 2014

I confirm this with Float field as well. It impacts fields which are automatically added as summed in tree view.

A workaround is to override read_group:

@api.model
def read_group(self, domain, fields, groupby, offset=0, limit=None,
               orderby=False, lazy=True):
    """ Remove computed Float fields from read_group to avoid
    AttributeError: 'NoneType' object has no attribute '_classic_write'
    due to odoo/odoo#3972
    """
    remove_fields = ('computed_field', )
    keep_fields = [f for f in fields if not f in remove_fields]
    _super = super(PurchaseOrderLine, self)
    return _super.read_group(domain, stored_fields, groupby=groupby,
                             offset=offset, limit=limit,
                             orderby=orderby, lazy=lazy)

yvaucher added a commit to yvaucher/vertical-ngo that referenced this issue Dec 4, 2014
yvaucher added a commit to yvaucher/vertical-ngo that referenced this issue Dec 5, 2014
nbessi added a commit to OCA/vertical-ngo that referenced this issue Dec 10, 2014
Workaround for odoo/odoo#3972 on group by in logistics requisition
@mart-e mart-e closed this as completed in 33c8aae Jan 5, 2015
@mart-e
Copy link
Contributor

mart-e commented Jan 5, 2015

Indeed an inssue with non-stored integer (or float) that could not be aggreated.
It was fixed at 33c8aae

yvaucher added a commit to yvaucher/vertical-ngo that referenced this issue Feb 3, 2015
lepistone added a commit to OCA/vertical-ngo that referenced this issue Feb 13, 2015
yvaucher added a commit to yvaucher/purchase-workflow that referenced this issue Mar 26, 2015
yvaucher added a commit to yvaucher/purchase-workflow that referenced this issue Mar 26, 2015
yvaucher added a commit to yvaucher/purchase-workflow that referenced this issue Apr 2, 2015
yvaucher added a commit to yvaucher/purchase-workflow that referenced this issue Apr 3, 2015
yvaucher added a commit to lepistone/purchase-workflow that referenced this issue Apr 6, 2015
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