Skip to Content
Menu
This question has been flagged
3 Replies
3570 Views

iam getting this error in my custom module , coz of this iam unable to start my server

   __import__('odoo.addons.' + module_name)
  File "/odoo/odoo-server/addons/transfers/__init__.py", line 4, in <module>
    from . import transfers
File "/odoo/odoo-server/addons/transfers/transfers.py", line 22
    @api.model
             ^
IndentationError: unindent does not match any outer indentation level - - -



transfers.py:



# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import models, fields, api , _



class Transfers(models.Model):
     _name ="transfers.name"
     _inherit = ['mail.thread','mail.activity.mixin']
     _description ="Transfer Record"

     transfers_Name = fields.Char(string="Name", required = True)
     transfers_ISO = fields.Char(string="ISO")
     transfers_amount = fields.Integer("Amount")
     notes = fields.Text(string ="Notes")
     image = fields.Binary(string ="Image")
     name = fields.Char(string='Order Reference', required=True, copy=False, readonly=True, states={'draft': [('readonly', False)]}, index=True, default=lambda self: _('New'))



    @api.model
    def create(self, vals):
        if vals.get('name', _('New')) == _('New'):

             vals['name'] = self.env['ir.sequence'].next_by_code('transfer.order.sequence', sequence_date=seq_date) or _('New')

        result = super(Transfers, self).create(vals)
        return result


sequence.xml:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data noupdate="1">

        <!-- Sequences for sale.order -->
        <record id="seq_transfers" model="ir.sequence">
            <field name="name">Transfer Order</field>
            <field name="code">transfer.order.sequence</field>
            <field name="prefix">T0</field>
            <field name="padding">5</field>
            <field name="company_id" eval="False"/>
        </record>

    </data>
</odoo>



manifest.py:

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

{
    'name': 'Transfers',
    'version': '1.0',
    'summary': 'Module for Money Transfer',
    'category': 'Extra Tools',
    'description':
    """
Transifex integration
=====================
This module will add a link to the Transifex project in the translation view.
The purpose of this module is to speed up translations of the main modules.

To work, Odoo uses Transifex configuration files `.tx/config` to detec the
project source. Custom modules will not be translated (as not published on
the main Transifex project).

The language the user tries to translate must be activated on the Transifex
project.
        """,
    'data': [
        'security/ir.model.access.csv' ,
        'data/sequence.xml' ,
        'transfers.xml',
       
    ],
    'depends': ['mail'],
    'installable':True,
    'application':True,
    'auto_install':False,
}



someone help iam a newbie to odoo13 development


Avatar
Discard
Best Answer

Hi, Guna


Kindly update the below code, Actually all fields which you defined inside the models contains extra space due to this you are getting the "Indentation" issue.
class Transfers(models.Model):
 
_name ="transfers.name"
  _inherit = ['mail.thread','mail.activity.mixin']
  _description ="Transfer Record"

  transfers_Name = fields.Char(string="Name", required = True)
  transfers_ISO = fields.Char(string="ISO")
  transfers_amount = fields.Integer("Amount")
  notes = fields.Text(string ="Notes")
  image = fields.Binary(string ="Image")
  name = fields.Char(string='Order Reference', required=True, copy=False, readonly=True, states={'draft': [('readonly', False)]}, index=True, default=lambda self: _('New'))

@api.model
def create(selfvals):
if vals.get('name', _('New')) == _('New'):
  vals['name'] = self.env['ir.sequence'].next_by_code('transfer.order.sequence'sequence_date=seq_date) or _('New')
  result = super(Transfers, self).create(vals)
return result

Feel free to ask in case you have any confusion related to the above points.
You may get undefined "seq_date" key error. So please don't forget to define this field inside the create method.

Thanks,
Ashish Singh (Team Lead)
Webkul Software Private Limited

Avatar
Discard
Best Answer

Hi
you did mistake on indentation. In most other programming languages, indentation is used only to help make the code look pretty. But in Python, it is required for indicating what block of code a statement belongs to.

please write code like this in .py file 

class Transfers(models.Model): _name ="transfers.name" _inherit = ['mail.thread','mail.activity.mixin'] _description ="Transfer Record" transfers_Name = fields.Char(string="Name", required = True) transfers_ISO = fields.Char(string="ISO") transfers_amount = fields.Integer("Amount") notes = fields.Text(string ="Notes") image = fields.Binary(string ="Image") name = fields.Char(string='Order Reference', required=True, copy=False,readonly=True, states={'draft': [('readonly', False)]}, index=True, default=lambda self: _('New')) @api.model def create(self, vals): if vals.get('name', _('New')) == _('New'): vals['name'] = self.env['ir.sequence'].next_by_code('transfer.order.sequence', sequence_date=seq_date) or _('New') result = super(Transfers, self).create(vals) return result


Avatar
Discard