Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
4925 Widoki

Hi all!,

I made a field with a module in sale.report. And now when i want to update a contact with my new field it throws this error, any idea?


File "/opt/odoo13/odoo/odoo/addons/base/models/ir_translation.py", line 558, in create
self.flush()
File "/opt/odoo13/odoo/odoo/models.py", line 5502, in flush
process(self.env[model_name], id_vals)
File "/opt/odoo13/odoo/odoo/models.py", line 5493, in process
recs._write(vals)
File "/opt/odoo13/odoo/odoo/models.py", line 3696, in _write
cr.execute(query, params + [sub_ids])
File "/opt/odoo13/odoo/odoo/sql_db.py", line 173, in wrapper
return f(self, *args, **kwargs)
File "/opt/odoo13/odoo/odoo/sql_db.py", line 250, in execute
res = self._obj.execute(query, params)
psycopg2.errors.ObjectNotInPrerequisiteState: cannot update view "sale_report"
DETAIL: Views containing GROUP BY are not automatically updatable.
HINT: To enable updating the view, provide an INSTEAD OF UPDATE trigger or an unconditional ON UPDATE DO INSTEAD rule.


My field in module:

x_studio_sector = fields.Char(String = "Sector", related='partner_id.industry_id.name', store=True)

Awatar
Odrzuć
Autor Najlepsza odpowiedź

I made a module to try to update the field but i'm getting the same error:


from odoo import _, exceptions, models, api, fields

class ResPartner(models.Model):

_inherit = 'res.partner'

@api.onchange('x_studio_sector')
def _onchange_x_studio_sector(self):
for rec in self:
parentIndustry = rec.industry_id
for child in rec.child_ids:
child.industry_id = parentIndustry

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

The sale.report model is not same as other models, if you check the original code, you can see that it is created using the query by fetching data from sale order line. You have to inherit the query and add the value to it. Please see the sale_margin module and see, how the margin field is inherited and added to the sale.report model.


Thanks

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
cze 21
5921
1
cze 20
3536
2
maj 24
1559
1
sie 21
2323
1
kwi 21
3755