How to delete a sales order which is in sales order status? - openerp-7

I am a newbie to openerp. I have a sales order under the module 'sales' which is in 'Sales Order' status. The order number is 'SO019' . And i want to delete this sales order in the list.
When i tried to delete this sales order i got the following OpenErp Warning
Invalid Action!
In order to delete a confirmed sales order, you must cancel it.
To do so, you must first cancel related picking for delivery orders.
But i have no option to cancel this delivery in the 'warehouse/Delivery Orders'
Instead of this i have the following two options
Print Delivery Slip
Return Products
When i click onto the Return products i am getting the following warning
Warning!
No products to return (only lines in Done state and not fully returned yet can be returned)!
Is there anyway that i can delete this sales order(SO019) in the sales orders list?
Thanks in advance..

When you save the Confirm Sale Order, The Delivery Order is made. So first you need to cancel first delivery order. In Delivery Order has button name Cancel Transfer.
If your delivery order is in Delivered state than you can not delete Sale Order.
At first time for Delivery Order, click on Return Product. The reverse entry is create. You can see that entry in Incoming Shipment. for example IN/001-OUT/002-return entry is created.
Now At Second time you click on Return Product from the Same Delivery order as you do above step than you got your above warning. Because you can not return product twice for same Delivery Order.
Hope this will help you.

If the column status shows 'Sales Order' that means your invoice for that order is created and you can not delete sale order until you delete invoice related to it or order is cancelled.
To delete sale order with status 'Sale order',
Short way:
1] Just click on 'Cancel Order' [and its automatically deleted]
(But invoice related to it is go to cancel state and is visible)
Long way
1] Go to Accounting-> customer invoice
2]Cancel invoice for your sale order.[Invoice status changed to 'Cancelled']
3]Delete that invoice [More-Delete]
4]Go to Sale->Sale Order [Now status is Changed to 'Invoice Exception']
5]Now click on your sale order and then 'Cancel Order' [Now its automatically deleted]

Related

How to get the number of customer invoices line?

I need a way to get all customer invoices line at an open state
If you need this value in dashboard then add computed field in dashboard model and calculate all open invoices there and add that in dashboard
#You first need to get the open invoices
open_invoices = self.env['account.invoice'].search([('state','=','open')])
#then get invoice lines
invoice_lines = open_invoices.mapped('line_ids')

Create a transfer order with an Empty Vendor number

I have a requirement where I have to create a transfer order with empty vendor.
The scenario is:
The client want maintains its in house stock, and in-house stock does not has any Special Stock no. (Vendo) in table LQUA.
If this stock is avaialble then the transfer order should be created with LTAP-SONUM = Empty.
I am trying the login in EXIT: EXIT_SAPLMDBF_002
I am currently applying C_XT434P-BPRIO = Empty and C_XT434P-LIFNR =
Empty in my EXIT after the stock validation.
But still SAP standard re-calculate the Vendor and assigns it an Consignment Vendor.
But if I assign an consignment vendor in the EXIT i.e. C_XT434P-BPRIO = 'K'and C_XT434P-LIFNR = Consignment Vendor no., then Transfer order is created with the vendor I have assigned.
Please help me in creating Transfer order with Empty Vendor.

SQL query to report on what invoices have not been paid, ordered by invoice number

new to SQL and only been doing it for a week and a half. So I apologise now for the question being simple or appearing to be stupid.
I want to present a report on invoices that have not been paid by a given date, ordered by invoice number.
This is how I have displayed, the paid invoices but without the given date.. How do I display, the invoices that have not been paid by say 31-MAR-14.
SELECT INVOICE.INVOICE_NUMBER, INVOICE.INVOICE_DATE, PAYMENT.PAYMENT_NO, PAYMENT.INVOICE_NUMBER
FROM INVOICE, PAYMENT
WHERE INVOICE.INVOICE_NUMBER = PAYMENT.INVOICE_NUMBER
ORDER BY INVOICE.INVOICE_NUMBER;
SELECT PAYMENT.PAYMENT_NO
FROM INVOICE, PAYMENT
WHERE INVOICE.INVOICE_NUMBER = PAYMENT.INVOICE_NUMBER
AND INVOICE.INVOICE_DATE = 'AAAAMMJJ'
ORDER BY INVOICE.INVOICE_NUMBER;
Try something like this.
I have question. How do you say the invoice are not paid ?
You need to join the two tables together with a LEFT JOIN, then look to see where the payment date is > 31-MAR-14. Try something like this:
SELECT INVOICE.INVOICE_NUMBER, INVOICE.INVOICE_DATE, PAYMENT.PAYMENT_NO, PAYMENT.INVOICE_NUMBER
FROM INVOICE
LEFT JOIN PAYMENT ON INVOICE.INVOICE_NUMBER = PAYMENT.INVOICE_NUMBER
WHERE PAYMENT.Date_of_payment > '3/31/2014'
ORDER BY INVOICE.INVOICE_NUMBER;
This looks for all payments that were made after 3/31/2014. You may need to add another condition, that limits what invoices you're looking for.
To check payments that have not been made, look where any field in the PAYMENT table is null. SQL like this:
SELECT INVOICE.INVOICE_NUMBER, INVOICE.INVOICE_DATE, PAYMENT.PAYMENT_NO, PAYMENT.INVOICE_NUMBER
FROM INVOICE
LEFT JOIN PAYMENT ON INVOICE.INVOICE_NUMBER = PAYMENT.INVOICE_NUMBER
WHERE INVOICE.INVOICE_DATE = '3/31/2014'
AND PAYMENT.PAYMENT_NO IS NULL
ORDER BY INVOICE.INVOICE_NUMBER;
LEFT JOIN in this case will always return values for the INVOICE table, but may return NULL values in place of the PAYMENT if a payment has not been entered yet. Checking AND PAYMENT.PAYMENT_NO IS NULL will tell you that a payment has not been made yet.

Updating a field within a table based on a field within the same table

HI ALL
I wish to update a row within my table from a row within that same table,
I have a table called INVENTORY. it stores PRICES for products.
I have SALES codes and I have STOCK codes which are related.
I wish to transfer all the PRICING from the SALES codes to the STOCK codes.
I wish to do something like this:
update INVENTORY
set PRICE = (SELECT PRICE WHERE CODE = "SALES CODE EQUIVALENT OF THE STOCK CODE IM IN")
WHERE
CODE = "SOME STOCK CODE"
a SALES CODE would look like this "U_12345", its STOCK code equivalent would look like "S_12345"
thanks
You're very close, you just need to specify which table you're selecting from as part of your sub-query...
update INVENTORY
set PRICE = (SELECT PRICE FROM your_table WHERE CODE = "SALES CODE EQUIVALENT OF THE STOCK CODE IM IN")
WHERE
CODE = "SOME STOCK CODE"
Even if "your_table" is INVENTORY, you still need to specify it in there.
The only time it gets 'tricky' is when your selecting from the same table that you're update, AND when you need a value from the updated record in the SELECT statement. In that case you need to differentiate between the two references, using an alias. For example...
update INVENTORY
set PRICE = (SELECT PRICE FROM INVENTORY AS [new_price] WHERE [new_price].CODE = INVENTORY.NEW_CODE)
WHERE
CODE = "SOME STOCK CODE"
UPDATE INVENTORY
SET PRICE = i_sales.PRICE
FROM INVENTORY, INVENTORY i_sales
WHERE INVENTORY.CODE LIKE 'S\_%'
AND i_sales.CODE = REPLACE(INVENTORY.Code, 'S', 'U')
This updates prices for all 'stock' records in INVENTORY with prices from the corresponding 'sales' records.
If you would prefer to update individual prices, change WHERE to something like this:
WHERE i_stock.CODE = 'S_12345'
or this:
WHERE i_stock.CODE IN ('S_12345', 'S_12346')
Note: The FROM syntax used is based on this doc page.

Tough SQL problem for an amateur like me

My family has several stock accounts, and I keep a table of stock values for their contents and enter current values daily. Fields are...
ACCOUNT / TICKER / QUANTITY / CLOSINGDATE/ CLOSING (current price)
To get a report of the current stock contents and most recent price, I am using this code. I add this up row by row, and get an account total (for account # 2, for example ). The table is designed this way also so I can track individual stock performance.
SELECT distinct ticker, account, closingdate, quantity, closing, (quantity*closing) as "Net"
FROM "stock values" AS S
WHERE
(account=2) and
(quantity>0.000001) and
(closingdate =(SELECT MAX(closingdate) FROM "stock values" WHERE ( ticker = S.ticker) and (account=s.account)) )
But now what I would like to do is create a report that looks like this on a TdbGrid so that... i get a report, grouped by account with the most recent distinct tickers added up FOR THAT ACCOUNT. Four days later, I cannot crack this.
Account Value
1 35,000.00
2 122,132,32
3 43.23
I'm using Nexus 3 on Delphi 7.
Any help, greatly GREATLY appreciated.
Larry
To me, it looks like you just have to add a group by:
select account
, sum(quantity*closing)
from "stock_values" as S
where s.closingdate =
(
select max(closingdate)
from "stock values" as S2
where S2.ticker = S.ticker
and S2.account = S1.account
)
group by
account
Since you can have the same stock across multiple accounts, I would pre-query the last closing date per stock per account... This way, if you have stock in company "X" and entered its daily balance for Feb 4th to Account #1, but forgot to enter the "X" price for Account #5, you would have each account with different "Last Date Entered" for a particular stock. It would actually be better to have two tables... one with nothing but your stocks, closing date and closing price. Then join that to the accounts that use those stocks... However, this query should get you a DETAILED breakdown per account showing all the maximum respective stock dates... The next query will be simplified for totals per account... This one is primarily for a sanity check to ensure you're getting what you expect. This does ALL the accounts, but you can adjust your WHERE clause to get only ONE specific account if you so need to.
SELECT
ticker,
account,
closingdate,
quantity,
closing,
(quantity*closing) as "Net"
FROM
"stock values" AS S,
( select account,
ticker,
max(closingdate) LastDatePerStock
from
"stock values" sMax
group by
account, ticker ) TickerDate
WHERE
s.account = TickerDate.account
and s.ticker = TickerDate.ticker
and s.closingdate = TickerDate.LastDatePerStock
and (quantity>0.000001)
order by
account,
ticker
Now, the query simplified with just the account and the closing balance for all their stocks without seeing exactly what stocks are in the portfolio.
SELECT
account,
max( closingdate ) LatestClosingDate,
sum((quantity*closing)) as "Net"
FROM
"stock values" AS S,
( select account,
ticker,
max(closingdate) LastDatePerStock
from
"stock values" sMax
group by
account, ticker ) TickerDate
WHERE
s.account = TickerDate.account
and s.ticker = TickerDate.ticker
and s.closingdate = TickerDate.LastDatePerStock
and (quantity>0.000001)
group by
account