Topic: sales_order_ui.inc has a bug

it looks like this now.

 
if ($order->fixed_asset)
            stock_disposable_fa_list_cells(null,'stock_id', null, _('[Select item]'), true, $order->line_items);
        else
        if (list_updated('stock_id')) {
            sales_items_list_cells(null,'stock_id', null, false, true, true);
            $Ajax->activate('price');
            $Ajax->activate('units');
            $Ajax->activate('qty');
            $Ajax->activate('line_total');
        } else
             sales_items_list_cells(null,'stock_id', last_sales_order_detail($order, 'stk_code'), false, true, true);

But it should be like this

if ($order->fixed_asset)
            stock_disposable_fa_list_cells(null,'stock_id', null, _('[Select item]'), true, $order->line_items);
        else
            sales_items_list_cells(null,'stock_id', null, false, true, true);
        if (list_updated('stock_id')) {            
            $Ajax->activate('price');
            $Ajax->activate('units');
            $Ajax->activate('qty');
            $Ajax->activate('line_total');
        } else
             sales_items_list_cells(null,'stock_id', last_sales_order_detail($order, 'stk_code'), false, true, true);
Subscription service based on FA
HRM CRM POS batch Themes

Re: sales_order_ui.inc has a bug

Fixed and sent to repo. Thanks @kvvaradha.

The fixed file can be downloaded here.

Joe

Re: sales_order_ui.inc has a bug

@joe ,sorry for my mistake.

the code should be like this.

if ($order->fixed_asset)
            stock_disposable_fa_list_cells(null,'stock_id', null, _('[Select item]'), true, $order->line_items);
        else
             sales_items_list_cells(null,'stock_id', last_sales_order_detail($order, 'stk_code'), false, true, true);
        if (list_updated('stock_id')) {            
            $Ajax->activate('price');
            $Ajax->activate('units');
            $Ajax->activate('qty');
            $Ajax->activate('line_total');
        }
            

By mistake i put in else part of list_updated.

Subscription service based on FA
HRM CRM POS batch Themes

Re: sales_order_ui.inc has a bug

Ok, @kvvaradha smile

Fixed and a new file can be downloaded here.

Joe

Re: sales_order_ui.inc has a bug

Will need to revert this commit - see this post.

What is the purpose of getting the last_sales_order_detail() field (in this case, 'stk_code' which is the stock_id)? Byusing this commit, we are making the default choice of the Item description select box override the actual selection made in it. Should this be restricted to only those with editable description alone if used at all?

Re: sales_order_ui.inc has a bug

@kvvaradha

Please make a comment on this. Do you agree with @apmuthu?

Joe

Re: sales_order_ui.inc has a bug

kvvaradha wrote:

@joe ,sorry for my mistake.

the code should be like this.

if ($order->fixed_asset)
            stock_disposable_fa_list_cells(null,'stock_id', null, _('[Select item]'), true, $order->line_items);
        else
             sales_items_list_cells(null,'stock_id', last_sales_order_detail($order, 'stk_code'), false, true, true);
        if (list_updated('stock_id')) {            
            $Ajax->activate('price');
            $Ajax->activate('units');
            $Ajax->activate('qty');
            $Ajax->activate('line_total');
        }
            

By mistake i put in else part of list_updated.

@joe - here I gave the same code exactly what he committed there. So you can update it.

Subscription service based on FA
HRM CRM POS batch Themes

Re: sales_order_ui.inc has a bug

@kvvaradha: Your Post #3 is the same as your post #7 which has been incorporated in this official commit which is what I would like to revert and make it as per my commit.

Re: sales_order_ui.inc has a bug

@kvvaradha.

Did you mean that it was ok to change the

line 505 in /sales/includes/ui/sales_order_ui.inc 
from:
            sales_items_list_cells(null,'stock_id', last_sales_order_detail($order, 'stk_code'), false, true, true);
to:
            sales_items_list_cells(null,'stock_id', null, false, true, true);

?

/Joe

Re: sales_order_ui.inc has a bug

@joe, Yes you are right.

As like @Apmuthu words, it rolls back to the last item sold to the customer. we are not able to change the item to sell. But we can try this option.it may be fessible to work on.

We will put an if condition, if the stock_id is not exist, we can get the last_sales_order_detail,like this, here is code

if ($order->fixed_asset)
            stock_disposable_fa_list_cells(null,'stock_id', null, _('[Select item]'), true, $order->line_items);
        else{
            if(!isset($_POST['stock_id'])){   // Check the stock id not exist
            $_POST['stock_id'] = last_sales_order_detail($order, 'stk_code');  //get the llast sales stock id.
        }
             sales_items_list_cells(null,'stock_id', last_sales_order_detail($order, 'stk_code'), false, true, true);
        }
        if (list_updated('stock_id')) {            
            $Ajax->activate('price');
            $Ajax->activate('units');
            $Ajax->activate('qty');
            $Ajax->activate('line_total');
        }

Hope this may be fixed the problem.

if not, we remove the function from sales_order_d.inc last_sales_order_detail. It was defined there. and keep the sales item list cells like this

sales_items_list_cells(null,'stock_id', null, false, true, true);
Subscription service based on FA
HRM CRM POS batch Themes

Re: sales_order_ui.inc has a bug

Ok, thanks @kvvaradha.

Committed and a new file here.

/Joe

Re: sales_order_ui.inc has a bug

!isset($_POST['stock_id'])

does not necessarily mean that the stock_id does not exist - it merely states that it was not chosen in the $_POST variable.

Re: sales_order_ui.inc has a bug

The new code works for now.
More testing is needed to check for edge conditions stated above.

I had to set config.php variable "$no_check_edit_conflicts = 1;" in windows for it to work though - it did not work for earlier commits.

Re: sales_order_ui.inc has a bug

For me it works fine.  If you  face problem with this. find a better solution for it. we will adapt to your solutions.  I tested it on Linux and Windows.  Both works fine for me

Subscription service based on FA
HRM CRM POS batch Themes