Odoo Help


9 Answers
6/22/17, 5:52 AM

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 !'),

    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" />

How to fix the problem ?

Mohammed Amal
6/22/17, 6:08 AM

You give your button action in "wizard.pivot.view" and button in "miadi.tarifs"

Mohammed Amal
6/22/17, 6:08 AM

also display button in form view not tree

6/22/17, 6:20 AM

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

6/22/17, 6:25 AM

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

Mohammed Amal
6/22/17, 6:47 AM

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

6/22/17, 7:30 AM

It worked in a post where you answered yesterday. So, why here it doesn't work ?

Mohammed Amal
6/22/17, 7:39 AM

I told you whats the error.

6/22/17, 7:50 AM

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.

6/22/17, 8:45 AM

I found the solution ! Thank you for your help

Tai Le Thanh
6/22/17, 6:17 AM

In the action

 <!-- action --> 
    <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>
I just know "view_type" which is the type of view when I click on a record
1 Comment
6/23/17, 7:58 AM

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'"

Ask a Question
Keep Informed
1 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now