Odoo Help

Welcome!

This community 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.

0

Additional column on product (template) variant list

By
Vincent Romagnoli
on 10/27/16, 11:57 AM 176 views

I'm using odoo v8 and I had create a new module to develop specific feature for my company.

My goal is to add an additional column in product template variant list (only on the display view not when editing or creating attribute) (http://www.files.com/image/58121ec64bf47/print1.png).

This column which contain the unit of measure of attribut was defined on product attribute configuration (http://www.files.com/image/5812239446f0f/print2.png).

I have identified that the field name I need to update is attribute_line_ids, it's right ? 


2

Nilmar Shereef

--Nilmar Shereef--
811
| 4 3 7
Calicut, India
--Nilmar Shereef--

Python Developer. Android Developer. .Net Developer

Nilmar Shereef
On 10/28/16, 12:52 AM

First you have to add a field uom_id to product.attribute.line class, and also you have to write a default function to get the value of uom with respect to product template. Also you have to mention the uom_id in tree view inside the product_view.xml .

0
Vincent Romagnoli
On 10/28/16, 2:52 AM

I don't want to add uom on product attribute line but on product attribute (because uom is the same for each attribute line). To do that I had already code py file:

# -*- coding: utf-8 -*-
from openerp import models, fields
class ProductAttribute(models.Model):
    _name = 'product.attribute'
    _inherit = 'product.attribute'
    uom_id = fields.Many2one('product.uom', 'Unit of Measure')

and the follow xml code:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
    <!-- Unit of Measure on Attributes Configuration -->
    <record id="attribute_uom_tree_view" model="ir.ui.view">
   <field name="name">product.attribute.tree.type</field>
        <field name="model">product.attribute</field>
        <field name="inherit_id" ref="product.attribute_tree_view"/>
            <field name="arch" type="xml">
            <field name="name" position="after">
                <field name="uom_id"/>
            </field>
        </field>
    </record>
</data>
</openerp>

 Now (in my understand of odoo) I need to find the page which display the table and add the column on tree view.

 

[edit 21 nov]

Finally I have found the solution. Add model relation:

class ProductAttributeLine(models.Model):
    _inherit = 'product.attribute.line' uom_id = fields.Many2one(related='attribute_id.uom_id', string='Unit of Measure', store=False, readonly=True)
 <record id="product_variant_list_view" model="ir.ui.view"> <field name="name">product.template.variant.form</field> <field name="model">product.template</field> <field name="type">form</field>  <field name="inherit_id" ref="product.product_template_only_form_view" />  <field name="arch" type="xml">    <field name="value_ids" position="after">     <field name="uom_id" />   </field> </field> </record>

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/27/16, 11:57 AM
Seen: 176 times
Last updated: 10/28/16, 2:52 AM