Skip to Content
Menu
This question has been flagged
1 Reply
3656 Views

Hello,

I need to edit the function action_move_create because I had edit the field amount_total

I need that debit in account_move_line to be equal to the new amount_total

I had tried this but I'm getting an error.

def action_move_create(self, cr, uid, ids, context=None):

res = super(snc_invoice, self).action_move_create(cr, uid, ids, context=context)

account_move = self.pool.get('account.move')

for inv in self.browse(cr, uid, ids, context=context):

res1 ={}

if inv.type == 'out_invoice':

sql = "update account_move_line set debit="+str(inv.amount_total) +",credit="+str(inv.amount_total) + " where move_id = " + str(inv.move_id.id)

cr.execute(sql)

return res

the error that  I'm getting :"

ValueError: "ERREUR: la nouvelle ligne viole la contrainte de v\xe9rification \xab account_move_line \xbb de la relation \xab account_move_line_credit_debit1 \xbb

DETAIL: La ligne en \xe9chec contient (104, 2016-04-22 11:30:12.059, null, 1, null, 2016-04-22, 8, null, f, null, 1, 1518.5, normal, 1, null, null, valid, 1518.5, null, 8, 5, 2016-04-22 11:30:12.059, 2016-04-22, 2016-04-22, 1, 32, /, null, 0.00, null, null, null, 0.00, 1.00)

" while evaluating

u'action_move_create()'

> f:\workspace_odoo\odoo-8.0\openerp\sql_db.py(234)execute()

-> res = self._obj.execute(query, params)

(Pdb)"

Any help please

Avatar
Discard
Best Answer

Try to avoid using cr.execute all you can:

for inv in self.browse(cr, uid, ids, context=context):
    inv.move_id.write(cr, uid, inv.move_id.id, {'debit': inv.amount_total, 'credit': inv.amount_total}, context=context)

Avatar
Discard
Author

Thanks for your answer but I'm still getting an error ValueError: "write() takes at most 6 arguments (9 given)" while evaluating u'action_move_create()' > f:\workspace_odoo\odoo-8.0\openerp\api.py(592)new_api() -> result = method(self._model, cr, uid, self.ids, *args, **old_kwargs) (Pdb)