Odoo Help


Does anyone here knows how to solve this error?? "Uncaught Error: NameError: name 'mem' is not defined"

on 1/13/15, 1:07 AM 1,811 views

Everything works fine at me local but when i've tried to put it in a testaddons(to test if my codes really works). I add a fields in JOURNAL ENTRIES but one field that has a name of 'mem' always appeared everytime i click the menu and the error keeps saying "Uncaught Error: NameError: name 'mem' is not defined".


Here's my code:


<!--*********************** Account.Entry Edition ****************** -->
        <record id="view_move_form" model="ir.ui.view">
            <field name="name">account.move.form</field>
            <field name="model">account.move</field>
            <field name="inherit_id" ref="account.view_move_form" />
            <field name="priority">1</field>
            <field name="arch" type="xml">
                    <xpath expr="//form/sheet/notebook/page/field[@name='line_id']" position="replace">
                         <field name="line_id" widget="one2many_list"
                              context="{'line_id': line_id , 'journal_id': journal_id, 'default_mem': mem, 'default_pr_num':pr_num, 'default_or_num':or_num, 'default_cv_num':cv_num, 'default_cheque_num':cheque_num,  }">

                                <form string="Journal Item" version="7.0">
                                    <group col="6" colspan="4">
                                        <field name="name"/>
                                        <field name="ref"/>
                                        <field name="partner_id" on_change="onchange_partner_id(False, partner_id, account_id, debit, credit, date, journal_id, context)"/>
                                        <field name="journal_id"/>
                                        <field name="period_id"/>
                                        <field name="company_id" required="1" groups="base.group_multi_company"/>
                                    <notebook colspan="4">
                                        <page string="Information">
                                                <group string="Amount">
                                                    <field name="account_id" domain="[('company_id', '=', parent.company_id), ('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
                                                    <field name="debit"/>
                                                    <field name="credit"/>
                                                    <field name="quantity"/>

                                                <group string="Accounting Documents">
                                                    <field name="invoice"/>
                                                    <field name="move_id" required="False"/>
                                                    <field name="statement_id"/>

                                                <group string="Dates">
                                                    <field name="date"/>
                                                    <field name="date_maturity"/>
                                                    <field name="date_created"/>

                                                <group string="Taxes">
                                                    <field name="tax_code_id"/>
                                                    <field name="tax_amount"/>
                                                    <field name="account_tax_id" domain="[('parent_id','=',False)]"/>

                                                <group string="Currency" groups="base.group_multi_currency">
                                                    <field name="currency_id"/>
                                                    <field name="amount_currency"/>

                                                <group string="Reconciliation">
                                                    <field name="reconcile_id"/>
                                                    <field name="reconcile_partial_id"/>

                                                <group string="States">
                                                    <field name="state"/>
                                                    <field name="blocked"/>

                                                <group groups="analytic.group_analytic_accounting" string="Analytic">
                                                    <field name="analytic_account_id"/>
                                            <separator string="Internal Note"/>
                                            <field name="narration"/>
                                        <page string="Analytic Lines" groups="analytic.group_analytic_accounting">
                                            <field colspan="4" name="analytic_lines" nolabel="1" context="{'default_general_account_id':account_id, 'default_name': name, 'default_date':date, 'amount': (debit or 0.0)-(credit or 0.0)}"/>
                                <tree colors="blue:state == 'draft';black:state == 'posted'" editable="top" string="Journal Items">
                                    <field name="invoice"/>
                                    <field name="name"/>
                                    <field name="partner_id" on_change="onchange_partner_id(False, partner_id, account_id, debit, credit, parent.date, parent.journal_id, context)"/>
                                    <field name="account_id" domain="[('journal_id','=',parent.journal_id),('company_id', '=', parent.company_id)]"/>
                                    <field name="date_maturity"/>
                                    <field name="debit" sum="Total Debit"/>
                                    <field name="credit" sum="Total Credit"/>
                                    <field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
                                    <field name="amount_currency"/>
                                    <field name="currency_id" groups="base.group_multi_currency"/>
                                    <field name="tax_code_id"/>
                                    <field name="tax_amount"/>
                                    <field name="state"/>
                                    <field name="reconcile_id"/>
                                    <field name="pr_num" invisible="True"/>
                                    <field name="or_num" invisible="True"/>
                                    <field name="cv_num" invisible="True"/>
                                    <field name="cheque_num" invisible="True"/>
                                    <field name="mem" invisible="True"/>

                                    <field name="reconcile_partial_id"/>


class account_move(osv.osv):
    _inherit = 'account.move'  

  _columns ={
               'or_num': fields.char('O.R. Number', size=50),
               'cheque_num': fields.char('Cheque Number', size=50),
               'pr_num': fields.char('P.R. Number', size=50),
               'cv_num': fields.char('C.V. Number', size=50),
               'mem':fields.char('Memo', size=50),





| 5 3 6
Jakarta, Indonesia
On 1/13/15, 1:26 AM

Your view is defined for account.move and then it displayed line_id (which is account.move.line, I believe).  The fields mem, pr_num, etc. fields are specified to be displayed for account.move.line (it is displayed from within the tree tag).  Now, what you have specified within the python is that those fields are defined for account.move but not displayed (I'm not sure if it is also defined for account.move.line but I presume they must be because there is no installation/upgrade error).

In order for the context to work, the fields used (mem, pr_num, etc.) need to be displayed for account.move's form view.  So, if you change add those fields into the view (not within the line_id fields but outside, or more specifically outside the xpath), it should work.

Thanks Ivan for your help:) i already solved the problem

on 1/13/15, 1:50 AM

Thanks Ivan for your help:) i already solved the problem

on 1/13/15, 1:51 AM

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

Question tools

1 follower(s)


Asked: 1/13/15, 1:07 AM
Seen: 1811 times
Last updated: 3/16/15, 8:10 AM