Hello,
In a personal module, I have a model and when I click on a record in the treeview, I have the form view to edit this record.
How to display another form view (like a pivot view or other) ?
Thanks for answers
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello,
In a personal module, I have a model and when I click on a record in the treeview, I have the form view to edit this record.
How to display another form view (like a pivot view or other) ?
Thanks for answers
Or, I found another solution : it's to add a button on each record to display the pivot view. but it's gives me this error :
AttributeError: type object 'miadi.tarifs' has no attribute 'display_pivot_view'
Here are my codes :
class miadi_tarifs(models.Model):
_name = 'miadi.tarifs'
code = fields.Char(string='Code', default='', required=True)
libelle = fields.Char(string='Libellé', default='', required=True)
remise = fields.Float(string='Remise', digits=(5,2), default=0)
_sql_constraints = [
('uniq_id', 'unique(code)', 'A pricelist already exists with this code. It must be unique !'),
]
@api.multi
def display_pivot_view(self):
tarif = self.code
return {'name': _('Pivot Lines'), 'view_type': 'form', 'view_mode': 'pivot,tree', 'view_id': False, 'views': [(self.env.ref('miadi_packaging.miadi_lignestarifs_pivot').id or False, 'pivot'), (self.env.ref('miadi_packaging.miadi_lignestarifs_tree').id or False, 'tree')], 'res_model': 'miadi.lignestarifs', 'type': 'ir.actions.act_window', 'target': 'current', 'domain': [('code_tarif', '=', tarif),]} #Retourne la vue tableau, la treeview et la vue formulaire
class miadi_lignesTarifs(models.Model):
_name = 'miadi.lignestarifs'
code_tarif = fields.Many2one('miadi.tarifs', 'Price Code', default='', required=True, ondelete='cascade')
numero_ordre = fields.Integer('Order number')
produit_id = fields.Many2one('product.product', 'Product', required=True, ondelete='cascade')
conditionnement_id = fields.Many2one('miadi.packaging', 'Packaging', required=True, ondelete='cascade')
prix_unitaire = fields.Float('Unit Price', default=0)
<record id="miadi_tarifs_tree" model="ir.ui.view">
<field name="name">miadi.tarifs.tree</field>
<field name="model">miadi.tarifs</field>
<field name="arch" type="xml">
<tree string="Prices" >
<field name="code" />
<field name="libelle" />
<field name="remise" />
<button name="display_pivot_view" type="object" string="Table view" class="oe_highlight" />
</tree>
</field>
</record>
How to fix the problem ?
You give your button action in "wizard.pivot.view" and button in "miadi.tarifs"
also display button in form view not tree
Yes I saw the error just before to see your comment.
I had a button in each record in the treeview because I want on click on the button to display the pivot view for this record
Can you help me ?
With the code in the answer, when I click oon the button for a record, it display the pivot form but with all records (all prices) but I want only the pivot view for the record where I click on the button. I don't know if you understand me
Pivot view is usually used for analysing all datas. There is no point in showing a single record.
Anyway you can achieve that by passing required filters
It worked in a post where you answered yesterday. So, why here it doesn't work ?
I told you whats the error.
Yesterday, in this post (mine) : https://www.odoo.com/fr_FR/forum/aide-1/question/how-to-display-a-pivot-view-after-a-form-view-depending-of-a-field-120339
You gave me a solution to have the pivot view depending of one field and here, it's the same but it doesn't work...
The difference is, instead of open a wizard with a field, I add a button directly in the record in the table where the field were selected.
I found the solution ! Thank you for your help
In the action
<!-- action -->I just know "view_type" which is the type of view when I click on a record
<record id="yourid" model="ir.actions.act_window">
<field name="name">....</field>
<field name="res_model">yourmodel</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
Hi, I tried to put "pivot" instead of "form" in the view_type and it gives me : ParseError: "Wrong value for ir.actions.act_window.view_type: 'pivot'"
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
2
Jun 17
|
3278 | ||
|
1
Sep 23
|
3581 | ||
|
2
May 21
|
2983 | ||
|
2
Jun 22
|
2746 | ||
|
0
Sep 21
|
1250 |
Hello Miadi,
Are you trying to add a pivot view for your model?
When I click on a menuitem, I have a treeview with some records and when I click on a record, I want to show a pivot view.
Instead of the form view that is display by default
I think what you are trying to achieve is making a pivot view for a single record instead of all the records of the model. As per my understanding this is not possible.
Please check what I post in an answer and tell me if it's possible please