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

Error while trying to add a new combo to res.partner

By
E.M.
on 9/19/15, 10:26 AM 602 views

Hi, I am trying to add a new combobox to re.partner (added field for customers). It is intended to provide an informative payment method selection and it should appear right after property_payment_term in the customer acountability tab.


This is my __init__.py:

from . import invoice_payment_method

this is my __openerp__.py:

{
'name': 'Payment Method Selection',
'description': 'Provides a new field to select payment method as per customer',
'author': 'E.M.',
'depends': ['base', 'account' ],
'data': ['invoice_payment_method.xml', ],
}

This is my invoice_payment_method.py:

# -*- coding: utf-8 -*-
from openerp import models, fields, api, exceptions

class invoice_payment_method(models.Model):

_inherit = "res.partner"

payment_method = fields.Selection(selection=[('bank_transfer', 'Transferencia Bancaria'),
('check', 'Cheque'),
('confirming', 'Confirming'),
string='Método de pago')


And this is invoice_payment_method.xml:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<record model="ir.ui.view" id="payment_method">
<field name="name">payment_method</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="account.view_partner_property_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='property_payment_term']" position="after">
<field name="payment_method"/>
</xpath>
</field>
</record>

</data>
</openerp>

Could anyone help me to identify what I am missing or how to further troubleshoot?

3

Axel Mendoza

--Axel Mendoza--
10308
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 9/20/15, 1:09 AM

You need to close the selection brackets in your field definition like:

payment_method = fields.Selection(selection=[('bank_transfer', 'Transferencia Bancaria'),
('check', 'Cheque'),
('confirming', 'Confirming')],#here
string='Método de pago')



0
Pouya Maleki
On 9/20/15, 12:13 AM

you should add _name to your class :


class invoice_payment_method(models.Model):
    _name = "res.partner"
    _inherit = "res.partner"


otherwise you are making a new class named  invoice_payment_method instead of editing res.partner. Also as a tradition, it is better to name your class "partner" instead of " invoice_payment_method"

Cheers,

Pouya

when you define _inherit and not _name is the same as declare _name and _inherit with the same value

Axel Mendoza
on 9/20/15, 1:07 AM

I didn't know it, thanks

Pouya Maleki
on 9/20/15, 2:52 AM

Actually, "Odoo Develpment Essentials" book states that while extending a class, no _name should be assigned. As per class name, if I understood it correctly, it can be the same as the extended one as they are just internal classes, my doubt is if there is any standard.

E.M.
on 9/20/15, 12:13 PM

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

2 follower(s)

Stats

Asked: 9/19/15, 10:26 AM
Seen: 602 times
Last updated: 9/21/15, 6:36 AM