Vauxoo / odoo-ifrs

Odoo ifrs_report module from addons-vauxoo
6 stars 26 forks source link

[FIX] A workaround to frozendict in new api for onchanges #24

Closed hbto closed 9 years ago

oscarolar commented 9 years ago

I Tried .copy with new API here is an example https://github.com/AlceConsorcio/odoo_cost_engineering/blob/master/mrp_bom_multilevel/wizard/replicate_boms.py#L75 There is also a method in the new API called .with_context()

alcedev commented 9 years ago

Perhaps something like this may come in handy: https://github.com/AlceConsorcio/odoo_cost_engineering/blob/master/mrp_bom_multilevel/product.py#L157

hbto commented 9 years ago

@nhomar I have not tried copy, but I thought about it, my rationale is that if we copy we will endup with and instance of the same frozendict, because frozencopy implements all the methods exception made to those ones that modify the dict.

@nhomar Your comment is quite valid.

@alcedev I can see that you implemented copy, but I cannot see that you mutated the ctx afterwards.

Can you provide an example where you implement mutation after copying a frozendict.

Best Regards.

hbto commented 9 years ago

@josemoralesp I think that your proposal is better than copy.

localcontext = dict(context) without iterations

You have implemented copy, I repeat, but you have not implemented mutation on the resulting copy.

Best Regards.

oscarolar commented 9 years ago

the @alcedev method actually mutates the context....

moylop260 commented 9 years ago

FYI you can use with context like this: wc

josemoralesp commented 9 years ago

someone :+1:

alcedev commented 9 years ago

Indeed, not in the original one per se. Nevertheless, as @moylop260 said, you could call something with the new one Like this. Best late than never, they say.

Cheers

hbto commented 9 years ago

@alcedev

    for field in fields_lst:
        if field.selectable:
            try:
                model_obj = self.env[field.model]
            except:

what does this piece of code refers to?

Can you make you point clear? please.

Regards.

alcedev commented 9 years ago

It is actually this code: _self = self.with_context(active_test=False, create_product_variant=True) ... _self.env['product.product'].create({'product_tmpl_id': tmpl_id.id, 'attribute_value_ids': [(6, False, values_ids)]})

Seems like the previous link now refers to another piece of code.

Just my 2 cents, cheers.