Odoo Help


how to get a status and change? [Closed]

Jair Walter
on 10/25/13, 2:26 PM 986 views

The Question has been closed for reason: duplicate question

Grover Menacho
on 10/25/2013 17:12:08

hello how to get a status and change?

The difficulty is in OpenERP 6.1 Server ubuntu 12:04 postgresql 9.1

I'm customizing the module "account_payment_extension" to better control check, created the status check (STATE_CHEQUE - "in cash", "another" and "used")

and 2 files (account_voucher.py and voucher_payment_receipt_view.xml), the changes are 90% ready.

When making the payment checks Open check if the status starts "in cash", if not status is "other" to this ok,

My doubt is the best way to change this status

STATE_CHEQUE "in cash" to "used"

file: account_voucher.py

import time from lxml import etree

import netsvc from osv import osv, fields import decimal_precision as dp from tools.translate import _

class account_voucher(osv.osv): _inherit = 'account.voucher'

_columns = {

   'move_line_id': fields.many2many('account.move.line', 'account_move_line_rel','voucher_id', 'move_line_id', 'Cheques', domain="[('state_cheque','=','caixa'), ('credit','=','0')]"),

def _state_cheque_get(self, cr, uid, ids, field_name, arg, context={}):        
    result = {}
    move_line_obj = self.pool.get('account.move.line')
    for rec in self.browse(cr, uid, ids, context):
        move_line_id = move_line_obj.search(cr, uid, [('state_cheque', '=', rec.state_cheque)], context=context)
        if move_line_id:
            inv = move_line_obj.browse(cr, uid, move_line_id[0], context)
            if inv.state_cheque:
                if inv.state_cheque == 'caixa':
                    self.write(cr, uid, ids, {'state_cheque': 'usado'})

                result[rec.id] = (0,0)
    return result



file: voucher_payment_receipt_view.xml

<openerp> <data>

<record model="ir.ui.view" id="view_cheque_vendor_payment_form">
      <field name="name">cheque.form</field>
      <field name="model">account.voucher</field>
      <field name="inherit_id" ref="account_voucher.view_vendor_payment_form"/>
      <field name="arch" type="xml">
        <xpath expr="/form/notebook/page/field[@name='line_dr_ids']" position="after">
          <group col="2" colspan="4">
           <separator string="Cheques Enviado" colspan="4"/>    
            <field name="move_line_id" widget="many2many" nolabel="1">
            <field name="partner_id" string="Cliente"/>
            <field name="partner_bank_id" string="Banco"/>
            <field name="numero_cheque"/>
            <field name="partner_id_emitente"/>
            <field name="debit" string="Valor" sum="debit"/>
            <field name="partner_bank_id_emitente"/>
            <field name="state_cheque"/>

</data> </openerp>

tks Jair

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

0 follower(s)


Asked: 10/25/13, 2:26 PM
Seen: 986 times
Last updated: 3/16/15, 8:10 AM