It is currently Sun Feb 12, 2012 6:41 pm

All times are UTC + 2 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: [Solved]XMLRPC:Object account.invoice.line.tax doesn't exist
PostPosted: Fri Feb 12, 2010 12:08 pm 
Offline

Joined: Fri Feb 12, 2010 11:52 am
Posts: 3
Hello,
I'm writing a Python (2.6) program that insert Invoices with XML RPC.
All is right except taxes : in fact I want to set a tax for each lines of an invoice. So the XML query is simply like this :

Code:
#taxe de la ligne
line_tax = {
    'invoice_line_id': line_id,
    'tax_id': tax_id
}

#creation de la taxe de la ligne   
    line_tax_id = sock.execute(oe_dbname, oe_uid, oe_pwd, 'account.invoice.line.tax', 'create', line_tax)

But it doesn't work and give me this error :
"Object account.invoice.line.tax doesn't exist"

The complete error result is :

Code:
Traceback (most recent call last):
  File "C:\Users\amozin.CORPIKOULA\Desktop\Tests_OpenERP_python\insertInvoice.py", line 264, in <module>
    line_tax_id = sock.execute(oe_dbname, oe_uid, oe_pwd, 'account.invoice.line.tax', 'create', line_tax)
  File "C:\Python26\lib\xmlrpclib.py", line 1199, in __call__
    return self.__send(self.__name, args)
  File "C:\Python26\lib\xmlrpclib.py", line 1489, in __request
    verbose=self.__verbose
  File "C:\Python26\lib\xmlrpclib.py", line 1253, in request
    return self._parse_response(h.getfile(), sock)
  File "C:\Python26\lib\xmlrpclib.py", line 1392, in _parse_response
    return u.close()
  File "C:\Python26\lib\xmlrpclib.py", line 838, in close
    raise Fault(**self._stack[0])
Fault: <Fault warning -- Object Error

Object account.invoice.line.tax doesn't exist: 'Traceback (most recent call last):\n  File "/usr/lib/python2.5/site-packages/openerp-server/netsvc.py", line 244, in dispatch\n    result = LocalService(service_name)(method, *params)\n  File "/usr/lib/python2.5/site-packages/openerp-server/netsvc.py", line 73, in __call__\n    return getattr(self, method)(*params)\n  File "/usr/lib/python2.5/site-packages/openerp-server/service/web_services.py", line 583, in execute\n    res = service.execute(db, uid, object, method, *args)\n  File "/usr/lib/python2.5/site-packages/openerp-server/osv/osv.py", line 63, in wrapper\n    self.abortResponse(1, inst.name, inst.exc_type, inst.value)\n  File "/usr/lib/python2.5/site-packages/openerp-server/netsvc.py", line 58, in abortResponse\n    raise Exception("%s -- %s\\n\\n%s"%(origin, description, details))\nException: warning -- Object Error\n\nObject account.invoice.line.tax doesn\'t exist\n'>

Other queries for the invoce are correct : create on account.invoice and account.invoice.line.
Does anyone have an idea or already met the problem?
Thanks ,


Last edited by Ammo on Fri Feb 19, 2010 10:59 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 12, 2010 5:09 pm 
Offline

Joined: Fri Feb 12, 2010 11:52 am
Posts: 3
OK,
I've got some news : in fact account.invoice.line.tax seems to be not concidered as an object as the same way as the others. I have to fix the taxes directly in the line's invoice :

Code:
            line = {
                'uos_id': uos_id,
                'name': description,
                'invoice_id': current_oe_invoice_id,
                'price_unit': float(amount),
                'account_id': account_line_id,
                'product_id': product_id,
                'invoice_line_tax_id': [(1)] #<- value??
            }

But I don't find the way to put my tax... how to value the 'invoice_line_tax_id' ??
Once I found the field invoice_line_tax_id' I've maid some search on the web to value it and found this :
Code:
            curr_line = {
               'price_unit': price,
               'quantity': qty,
               'discount':factor.factor,
               'invoice_line_tax_id': [(6,0,tax )],
               'invoice_id': last_invoice,
               'name': factor_name,
               'product_id': product_id,
               'uos_id': product.uom_id.id,
               'account_id': account_id,
               'account_analytic_id': account.id,
            }

with the 'tax' variable init like this :
Code:
taxep = account.partner_id.property_account_tax
            if not taxep.id:
               tax = [x.id for x in taxes or []]
            else:
               tax = [taxep.id]
               for t in taxes:
                  if not t.tax_group==taxep.tax_group:
                     tax.append(t.id)

So I think that it's just a table? How to put my id tax? Maybe there is differents values to put and not only the tax id?
Someone can help me? Thanks!

Sorry if my english seems you bad, my natural language is french.[/code][/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 12, 2010 5:52 pm 
Offline

Joined: Fri Feb 12, 2010 11:52 am
Posts: 3
Solution found!!!

I've found the information there :http://openobject.com/wiki/index.php/Developers:Developper%27s_Book/Objects/ObjectsAccess/ObjectsWritingValues

so the argument for 'invoice_line_tax_id' has this form : [(op, id, values)]
Quote:
Where

* op: the type of operation (link, create, remove, ...)
* id: the ID of the resource (in case of a modification or unlink)
* values: a dictionary of values for the distant record

Possible values for op:

* 0: create
* 1: write
* 2: unlink
* 6: set the link to a list of IDs given in the third argument (values)

The one2many fields are working like that! Great, the information exists but I didn't found it quickly...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 2 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:

Protected by Anti-Spam ACP