Odoo Help


This community 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.


Edit action_move_create in account_invoice

on 4/22/16, 7:30 AM 304 views


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)


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


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

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


Any help please

Jorge Barcelo Cortes
On 4/22/16, 8:04 AM

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)

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)

on 4/22/16, 9:21 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 4/22/16, 7:30 AM
Seen: 304 times
Last updated: 4/25/16, 3:33 AM