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'})
else:
result[rec.id] = (0,0)
return result
account_voucher()
and
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">
<tree>
<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"/>
</tree>
</field>
</group>
</xpath>
</field>
</record>
</data> </openerp>
tks Jair