i want to add a new field to an existing module odoo11 but i dont know why it didnt work

2024/7/6 22:46:32

product_template.xml

the view to add the customizing field to the product module

<?xml version="1.0" encoding="utf-8"?><odoo><data><record id="product_template_only_form_view_inherit" model="ir.ui.view"><field name="name">product.template.common.form</field><field name="model">product.template</field><field name="inherit_id" ref="product.product_template_only_form_view " /><field name="arch" type="xml"><xpath expr="//field[@name='list_price']" position="after"><field name="list_price"/></xpath></field></record></data></odoo>

models file python

product_template.py

-- coding: utf-8 --

from odoo import models, fields , api

from odoo.addons import decimal_precision as dp

from odoo.exceptions import ValidationError, RedirectWarning, except_orm

from odoo.tools import pycompat

class ProductTemplate(models.Model):

_inherit = 'product.template'

_name = 'product.template'_columns={'remise': fields.float('remise du fournisseur', size=10, required=True),'marge': fields.float('marge', size=10, required=True),'total_reste': fields.float('Reste', size=10, required=True),}remise = fields.float('remise du fournisseur', size=10, required=True)
Answer

You are putting the same field list_price after list_price, you should replace the field that is inside the xpath by the field you want.

<record id="product_template_only_form_view_inherit" model="ir.ui.view"><field name="name">product.template.common.form</field><field name="model">product.template</field><field name="inherit_id" ref="product.product_template_only_form_view " /><field name="arch" type="xml"><xpath expr="//field[@name='list_price']" position="after"><field name="your_custom_field"/></xpath></field></record>

https://en.xdnf.cn/q/120580.html

Related Q&A

How to check with more RegEx for one address in python using re.findall()

How to check with more RegEx for one address in python using re.findall()Ex: I want to apply the below regex rules # need to get addresstxt = "hello user 44 West 22nd Street, New York, NY 12345 fr…

Finding all roots of an equation in Python

I have a function that I want to find its roots. I could write a program to figure out its roots but the point is, each time that I want to find the other root I should give it an initial value manuall…

defining matrix class in python

Define a class that abstracts the matrix that satisfies the following examples of practice

Why do round() and math.ceil() give different values for negative numbers in Python 3? [duplicate]

This question already has an answer here:What is the algorithmic difference between math.ceil() and round() when trailing decimal points are >= 0.5 in Python 3?(1 answer)Closed 6 years ago.Why do r…

getting the value from text file after the colon or before the colon in python

I only need the last number 25 so i can change it to int(). I have this text file:{"members": [{"name": "John", "location": "QC", "age": 25}…

How to remove the background of an object using OpenCV (Python) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.Want to improve this question? Add details and clarify the problem by editing this post.Closed 3 years ago.Improve…

How to move zeros to the end of a list [closed]

Closed. This question needs debugging details. It is not currently accepting answers.Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to repro…

My program only appends one user input to list when main is looped

This is part of my code for a guessing game. I want to count the guesses of a player, and then append their name and number of guesses to a list that is later written or appended to file. As of now, it…

How to split a python dictionary for its values on matching a key

my_dict1 = {a:1, chk:{b:2, c:3}, e:{chk:{f:5, g:6}} }I would like to loop through the dict recursively and if the key is chk, split it. Expected output:{a:1, b:2, e:{f:5}} {a:1, c:3, e:{f:5}} {a:1, b:2…

PyException: ImportError: No module named domreg

I am getting the below error while running this script ("from xml.dom import minidom") from chaquopy androi application python console. PyException: ImportError: No module named domreg