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

How to correct this error in module?

By
Diogenes Ojeda
on 2/10/15, 7:55 PM 782 views

Hi all, I'm rehearsing create a simple module Odoo, and I find a mistake. So that they can guide me correctly, here is the step of creating my module:

I have the following files:

__init__.py which reads: import margins

__margenes__.py whose content is:

OpenERP from import models, fields, api

silkworm_sale_order class (models.Model):
     _inherit = 'sale.order'

     _columns = {
         'x_daterequired': fields.date ('Date Required'),
         'x_rush': fields.boolean ("Rush Order"),
         }

The idea is to add in the form of an order to sell a required field with a boolean.

Of course I have the openerp.py file whose content is:

{
     'name': 'Screen Printing',
     'version', '1.0',
     'description': "" "
     This module adds functionality for
          screen printing companies
     "" "
     'author', 'Diogenes Ojeda'
     'depends': ['base', 'sale'],
     'data': ['vista_margenes.xml'],
     'demo': [],
     'installable': True,
     'auto_install': False,
}
 

And finally the vista_margenes.xml file whose content is this:


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

<OpenERP>
     <data>
        <record id = "sale_view_order_form" model = "ir.ui.view">
          <field name = "model"> sale.order </ field>
          <field name = "inherit_id" ref = "sale.view_order_form" />
          <field name = "arch" type = "xml">
            <field name = "client_order_ref" position = "after">
              <field name = "x_daterequired" />
              <field name = "x_rush" />
            </ field>
        </ record>
     </ data>
</ openerp>

The module appears to me on the list of modules to install without problems,

but when I try to install, I get the following error:

 

The module appears to me on the list of modules to install without problems,

but when I try to install, I get the following error:

Traceback (most recent call last):
   File "C: \ Program Files \ Odoo 8.0-20150114 \ server \ \ openerp \ http.py.", Line 525, in _handle_exception
   File "C: \ Program Files \ Odoo 8.0-20150114 \ server \ \ openerp \ http.py.", Line 562, in dispatch
   File "C: \ Program Files \ Odoo 8.0-20150114 \ server \ \ openerp \ http.py.", Line 302, in _call_function
   File "C: \ Program Files \ Odoo 8.0-20150114 \ server \ \ openerp \ service \ model.py.", Line 113, in wrapper
   File "C: \ Program Files \ Odoo 8.0-20150114 \ server \ \ openerp \ http.py.", Line 299, in checked_call

File "C: \ Program Files \ Odoo 8.0-20150114 \ server \ \ openerp \ http.py.", Line 791, in __call__
   File "C: \ Program Files \ Odoo 8.0-20150114 \ server \ \ openerp \ http.py.", Line 395, in response_wrap
   File "C: \ Program Files \ Odoo 8.0-20150114 \ server \ openerp \ addons \ web \ controllers \ main.py", line 953, in call_button
   File "C: \ Program Files \ Odoo 8.0-20150114 \ server \ openerp \ addons \ web \ controllers \ main.py", line 941, in _call_kw
   File "C: \ Program Files \ Odoo 8.0-20150114 \ server \ \ openerp \ api.py.", Line 237, in wrapper
   File "C: \ Program Files \ Odoo 8.0-20150114 \ server \ openerp \ addons \ base \ module \ module.py", line 450, in button_immediate_install
   File "C: \ Program Files \ Odoo 8.0-20150114 \ server \ \ openerp \ api.py.", Line 237, in wrapper
   File "C: \ Program Files \ Odoo 8.0-20150114 \ server \ openerp \ addons \ base \ module \ module.py", line 498, in _button_immediate_function
   File "C: \ Program Files \ Odoo 8.0-20150114 \ server \ \ openerp \ modules \ registry.py.", Line 346, in new

File "C:. \ Program Files \ Odoo 8.0-20150114 \ server \ \ openerp \ modules \ loading.py", line 363, in load_modules
   File "C:. \ Program Files \ Odoo 8.0-20150114 \ server \ \ openerp \ modules \ loading.py", line 263, in load_marked_modules
   File "C:. \ Program Files \ Odoo 8.0-20150114 \ server \ \ openerp \ modules \ loading.py", line 149, in load_module_graph
   File "C: \ Program Files \ Odoo 8.0-20150114 \ server \ \ openerp \ modules \ module.py.", Line 312, in load_openerp_module
   File "C: \ Program Files \ Odoo 8.0-20150114 \ server \ \ openerp \ modules \ module.py.", Line 77, in load_module
   File "C: \ Program Files \ Odoo 8.0-20150114 \ server \ openerp \ addons \ margen_producto \ __ init__.py", line 1, in <module>
   File "C: \ Program Files \ Odoo 8.0-20150114 \ server \ openerp \ addons \ margen_producto \ margenes.py", line 4, in <module>
   File "C: \ Program Files \ Odoo 8.0-20150114 \ server \ openerp \ addons \ margen_producto \ margenes.py", line 8 in silkworm_sale_order
TypeError: an integer is required

 


I do not know how to fix it! Help.

Thank You

 

0

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
3918
| 5 3 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 2/11/15, 1:05 AM

__init__.py
import margins

__openerp__.py
{
     'name': 'Screen Printing',
     'version', '1.0',
     'description': "" "
     This module adds functionality for
          screen printing companies
     "" "
     'author', 'Diogenes Ojeda'
     'depends': ['base', 'sale'],
     'data': ['vista_margenes.xml'],
     'demo': [],
     'installable': True,
     'auto_install': False,
}

margins.py    # Name according to your import at __init__.py
from openerp
import models, fields, api     # check on how import statements used at python

class silkworm_sale_order(models.Model):   # Class should be defined first then its class name
     _inherit = 'sale.order'
     _columns = {
         daterequired': fields.date ('Date Required'),   
         rush': fields.boolean ("Rush Order"),     # Also naming of fields should not contain "x_", usually x_ is used when creating a new field via User Interface i.e. from odoo itself
         }

vista_margenes.xml
<? xml version = "1.0" encoding = "utf-8"?>
<openerp>      <!-- open and closing tags should match @ XML -->
     <data>
        <record id = "sale_view_order_form" model = "ir.ui.view">
          <field name = "model">sale.order</ field>      <!-- NO Extra space(whitespace) with value for an attribute -->
          <field name = "inherit_id" ref = "sale.view_order_form" />
          <field name = "arch" type = "xml">
            <field name = "client_order_ref" position = "after">
              <field name = "daterequired" />
              <field name = "rush" />
            </field>
        </record>
     </data>
</openerp>
 

0
Diogenes Ojeda
On 2/11/15, 8:49 AM

Hello,

you point out these errors do not exist in the original code, that is correct.

You see them in this forum, because I used a Spanish-English translator, but the code is correct.

But even when this error all right, when trying to install, comes:


TypeError: an integer is required


Thank You

-1
Mohammed Roshan
On 2/11/15, 12:06 AM

_columns = {
         'x_daterequired': fields.date ('Date Required'),
         'x_rush': fields.boolean ("Rush Order"), #There is an extra comma here " , "  , delete it
         }

Mohammed while the correct way to code this is without a comma on the last line it will also work with the comma on the last record in a column. Its a choice and I believe the rule of thumb is to not place a , after the last record. It won't cause any errors or problems if you do so though!

Yenthe
on 2/11/15, 2:28 AM

Hello, you point out these errors do not exist in the original code, that is correct. You see them in this forum, because I used a Spanish-English translator, but the code is correct. But even when this error all right, when trying to install, comes: TypeError: an integer is required Thank You

Diogenes Ojeda
on 2/11/15, 8:50 AM

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: 2/10/15, 7:55 PM
Seen: 782 times
Last updated: 3/16/15, 8:10 AM