Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to set the traceability fields in OpenERP(Odoo)?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 375
    Comment on it

    In traceability fields first we have to go in .py file (Python file) After that we have to decide where we want traceability fields and then give start to end Path to that field.Use below .py code in python file:

    'date': fields.date('Entry Date', required=True, readonly=True),
            'user_id': fields.many2one('res.users','User', readonly=True),
            'update_date': fields.date('Update Date',readonly=True),
            'update_by': fields.many2one('res.users', 'Updated by', readonly=True),        
        }
        _defaults = {
            'type': _get_type,
            'state': 'draft',
            'day_count_basis': '360',
            'date': lambda *a: time.strftime('%Y-%m-%d'),
            'user_id': lambda self,cr,uid,context: uid,
            'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'account.coda', context=c),
        }        
    
        def onchange_date(self, cr, uid, ids, date_start, date_stop):
            if not (date_start and date_stop):
                return {}
            res = {}
            date_start = datetime.strptime(date_start, '%Y-%m-%d').date()
            date_stop = datetime.strptime(date_stop, '%Y-%m-%d').date()
            nbr_days = (date_stop - date_start).days
            if nbr_days < 1 :
                raise osv.except_osv(_('Error!'), _('Invalid Date Range!'))
                return {}
            return {'value':{'days': nbr_days}}
    
        def button_confirm(self, cr, uid, ids, context=None):   
            if context is None:
                context = {}
            seq_obj = self.pool.get('ir.sequence')
            seq_sl_code = 'account.straight.loan.demand'
            seq_pl_code = 'account.placement.demand'
            cfpline_obj = self.pool.get('account.cashflow.provision.line')
            for demand in self.browse(cr, uid, ids, context=context):
                # amount_main provision
                cfpline_obj.create(cr, uid, {
                    'origin': demand._name + ',' + str(demand.id),
                    'description': (demand.description and (demand.description + ' - ') or '') + _('Transaction Amount'),
                    'state': 'confirm',
                    'journal_id': demand.journal_id.id,
                    'val_date': demand.date_start,  
                    'amount': demand.type == 'loan' and demand.amount_main or -demand.amount_main,
                    'cashflow_code_id': demand.cfc_id_main_start.id,
                    }, context=context)
                cfpline_obj.create(cr, uid, {
                    'origin': demand._name + ',' + str(demand.id),
                    'description': (demand.description and (demand.description + ' - ') or '') + _('Transaction Amount'),
                    'state': 'confirm',
                    'journal_id': demand.journal_id.id,
                    'val_date': demand.date_stop,  
                    'amount': demand.type == 'loan' and -demand.amount_main or demand.amount_main,
                    'cashflow_code_id': demand.cfc_id_main_stop.id,
                    }, context=context)

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: