Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
7514 Weergaven

Hi Everyone !
I am trying to create dynamic view ,  so i want to create views in python side . But when i try to save the view the "arch_base" field is not set . Can someone tell me what's the problem ? Here is my function 


@api.onchange('field_id')
def create_validation_button(self):
model = self.field_id.model_id.model
model_view = self.env['ir.ui.view'].search([("model", "=", model), ('type', "=", "form")])
arch = '<xpath expr="//header" postition="inside"><button string="Add Followers" type="object" name="add_project_followers" /></xpath>'
if model_view:
self.view_id = None
self.env['ir.ui.view'].search(
[("model", "=", model), ('name', "=", 'validation.' + model_view.name)]).unlink()
view_data = {'name': 'validation.' + model_view.name, 'type': 'form', 'model': model, 'priority': 1,
'inherit_id': model_view.id,
'mode': 'extension',
'arch_base': arch.encode('utf-8')}
view = self.env["ir.ui.view"].create(view_data)
self.view_id = view
Avatar
Annuleer
Beste antwoord

Do you not want to be writing to the field `arch`, not `arch_base`?

Either way this seems pretty hinky, and there may well be an easier way to do this just via XML, though I can't quite understand what you're trying to accomplish with the above code

Avatar
Annuleer
Auteur

thank you , it works .

Glad to hear it!

Gerelateerde posts Antwoorden Weergaven Activiteit
1
mrt. 15
5380
1
mrt. 24
2746
3
aug. 22
11898
2
feb. 19
4107
2
jun. 16
6006