Community mailing list archives

community@mail.odoo.com

Re: error accessing wizard via xmlrpc

by
Chris Jones
- 02/13/2016 14:25:05
split_wiz_id = split_obj.create(cr, uid, {'product_uom': stock_sql_res['uom_id'], 'product_id': stock_sql_res['product_id'], 'qty': stock_sql_res['product_qty'], 'use_exist': 'True', 'line_exist_ids':{ 'prodlot_id': stock_sql_res['prodlot_id'], 'quantity': stock_sql_res['product_qty']} }, context )

line_ids = context['active_ids']
split_obj.split(cr, uid, [split_wiz_id], line_ids, context=context)

When I print split_wiz_id and line_ids I get what look like good values, line_ids matches the row number of the stock.move I'm trying to split. 

When the last line runs I get AssertionError: Incorrect use of the stock move split wizard

That error seems to be coming from stock_move.py in the stock module. Here's the relevant code: 

def split(self, cr, uid, ids, move_ids, context=None):
        """ To split stock moves into serial numbers
        :param move_ids: the ID or list of IDs of stock move we want to split
        """
        if context is None:
            context = {}
        assert context.get('active_model') == 'stock.move',\
             'Incorrect use of the stock move split wizard'





On Sat, Feb 13, 2016 at 12:42 AM, Jay Vora <vora.jay@serpentcs.com> wrote:
Chris,

Call to split should be like recordset.split(cr, uid, ids, line_ids, context=context)

In your call, make sure the IDs should be a list, line_ids should be list of stock.moves IDs.

So, it should not be :split_obj.split(cr, uid, [split_wiz_id], context=context);
Rather it should be split_obj.split(cr, uid, [split_wiz_id], line_ids, context=context)

Most probably, you would get line_ids = context['active_ids'] as its called from move.

Hope this helps.
Thanks,

On Sat, Feb 13, 2016 at 4:28 AM, Chris Jones <chris.jones@saasier.com> wrote:
That was a dumb miss on my part!! Thanks for the response. 

Now I get this message: TypeError: split() takes at least 5 arguments (5 given)

The split function in stock module is:
def split(self, cr, uid, ids, line_ids, context=None):
        """ To split stock inventory lines according to serial numbers.
        :param line_ids: the ID or list of IDs of inventory lines we want to split
        """

I'm passing split_wiz_id for line_ids, what do I pass for ids? 

On Fri, Feb 12, 2016 at 12:57 PM, Julio serna Hernandez <julio@vauxoo.com> wrote:
Hello

quantity should be 'quantity'

Like this,
split_wiz_id = split_obj.create(cr, uid, {'product_id': stock_sql_res['product_id'], 'qty': stock_sql_res['product_qty'], 'use_exist': 'True', 'line_exist_ids':{ 'prodlot_id': stock_sql_res['prodlot_id'], 'quantity': stock_sql_res['product_qty']} }, context )




2016-02-12 14:47 GMT-06:00 Chris Jones <chris.jones@saasier.com>:
I have a custom function that calls the stock serial split function in Manufacturing Order in v7.0. It's sitting in a custom function called via xmlrpc from a mobile app. 

I'm using the following code: 

split_obj = self.pool.get('stock.move.split')

split_wiz_id = split_obj.create(cr, uid, {'product_id': stock_sql_res['product_id'], 'qty': stock_sql_res['product_qty'], 'use_exist': 'True', 'line_exist_ids':{ 'prodlot_id': stock_sql_res['prodlot_id'], quantity: stock_sql_res['product_qty']} }, context )

split_obj.split(cr, uid, [split_wiz_id], context=context)

the stock_sql_res are returned from a select statement. When I run this I get a message that says 

NameError: global name 'quantity' is not defined

line_exist_ids is a many2one field and the fields inside that are prodlot_id and quantity. The prodlot_id and quantity are ultimately going in stock.move and not in stock.move.split but I'm not sure how to feed them in in this query. I know I'm missing something obvious but I'm not sure what it is. 



--
Chris Jones
SaaSier.com
Open Source ERP Solutions
Skype: chrishjones20 - Preferred Contact Method

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe




--
Julio Serna
Vauxoo

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe




--
Chris Jones
SaaSier.com
Open Source ERP Solutions
Skype: chrishjones20 - Preferred Contact Method

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe




--

The Splendid journey of 4 years in Numbers
---
Regards,
----------------------------------------------------------------------------------------------------------------------------
Jay Vora
Managing Director


 
Direct: +91-9879354457
Office: +91-9033472982
Skype: jaynvora
Twitter : jaynvora
   
-------------------------------------------------------------------------------------------------
Visit our website : http://www.serpentcs.com
Please consider the environment before printing this email

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe




--
Chris Jones
SaaSier.com
Open Source ERP Solutions
310-400-0256
Skype: chrishjones20 - Preferred Contact Method