keep buy position open , when sell signal apears - conditional-statements

buy=ta.crossover(s2,0) , i want to keep my buy position open to stoploss , even when a get a sell entry,
if( buy )
strategy.entry("buyentry", strategy.long)
strategy.exit("stopbuy","buyentry",qty_percent=percentageclose, limit=profitbuy , stop=trailingactivat==true?trailinglongprice:stopbuy)
//strategy.close("buyentry", when=stopbuy1,qty_percent=percentageclose)
if(sell)
strategy.entry("sellentry", strategy.short)
strategy.exit("stopsell","sellentry",qty_percent=percentageclose,limit=profitsell, stop =trailingactivat==true? trailingshortprice:stopsell)
//strategy.close("sellentry",when=stopsell1, qty_percent=percentageclose)

Related

No default debit and credit account defined on journal - Odoo v13

I have created a point of sale and I have changed the currency in the journals from USD to MXN, when closing the point of sale, I get the following error: "No default debit and credit account defined on journal Efectivo (ids: [10 ]). "
I understand that I must go to the Efectivo journal and there place the default debit and credit data. But there is nothing like that in the journal.
I have changed the journal to Sales, Bank and each of the options in the drop-down list, none of them comes "Debit" or "Credit account"
All this happens when you change the currency from USD to MXN.
I have tried this in different ways, in different databases, with and without demo information and I always get the same error.
I don't know what to do to repair it.
I resolve this issue.
i went to the terminal and connected to my DB:
There i find the column default_credit_account_id and default_debit_account_id and it was empty on account_journal.
The others had a integer value.
select * from account_journal
So i guess these values comes from account_account, and since i am defining cash (Efectivo), i selected that.
select * from account_account
You can query that table and verify that which account do you want.
Finally i update the table account_journal.
update account_journal set default_credit_account_id = 39, default_debit_account_id = 39 where id=11;
Remember, the id is from your account_journal

SQL Partition By Query

Looking for help with a TSQL query.
Lets say you are building Kitchen Cabinets. There are numerous parts to build 1 cabinet and a kitchen in turn will have numerous cabinets. Lets also say that we have 3 different types of cabinets (floor, upper and tall).
We have rack(s) where we want to put all the parts required to build the kitchen. However, we want to keep everything organized. So, Cabinet 1, we want to keep all its parts together.
Our Rack has numerous slots (so many per type of cabinet..upper, floor, tall). The slots can only hold so many pieces before it needs to spill over to the next slot.
So our database has a list of all the parts required per cabinet that is needed. The goal is to associate each part with a rack and slot #. We also know that there are cases where 1 cabinet will need numerous slots and a kitchen may require numerous racks.
How can you write a query to do this. Sample data below:
So The goal (referencing the row number - slot number).
1-1, 2-2, 3-3, 4-3, 5-3, 6-3, 7-3, 8-3, 9-4, 10-4......
Cabinet ID 32 needs 3 slots. So we want to show that you are going to start in slot 3, fill it, move to slot 4, fill it and then move on to slot 5.
I have separate tables that tell me how many slots per slot type are in a rack.
I am using the following so far:
SELECT TOP (100) PERCENT dbo.[CAD-CV-Cabinets].[Cabinet ID] ,
dbo.[CAD-CV-Parts].Width ,
dbo.[CAD-CV-Parts].Length ,
dbo.[CAD-CV-MateriaIs].Name ,
dbo.[CAD-CV-Parts].AutoID ,
dbo.[CAD-CV-Cabinets].[Cabinet Type] ,
CASE WHEN [CAD-CV-Parts].Width > 40
OR [CAD-CV-Parts].Width > 40
OR [CAD-CV-Cabinets].[Cabinet Type] IN(3) THEN 'Tall'
WHEN [CAD-CV-Cabinets].[Cabinet Type] IN(1 , 12 , 4 , 5 , 6 , 7) THEN 'Lower'
WHEN [CAD-CV-Cabinets].[Cabinet Type] IN(2 , 9 , 8 , 10 , 11 , 13 , 14) THEN 'Upper'
ELSE 'No Cart' END AS SlotType,
CASE WHEN [CAD-CV-Parts].Width > 40
OR [CAD-CV-Parts].Width > 40
OR [CAD-CV-Cabinets].[Cabinet Type] IN(3)
THEN ceiling(SUM(2) OVER (PARTITION BY [CAD-CV-Cabinets].[Cabinet ID] ORDER BY dbo.[CAD-CV-Parts].AutoID) / (select min(SlotWidth) from CartDetails where SlotType = 'Tall'))
end TallSlotCount FROM dbo.[CAD-CV-Cabinets]
INNER JOIN
dbo.[CAD-CV-Parts]
ON dbo.[CAD-CV-Cabinets].[Cabinet ID] = dbo.[CAD-CV-Parts].CabinetID
INNER JOIN
dbo.[CAD-CV-MateriaIs]
ON dbo.[CAD-CV-Parts].MaterialID = dbo.[CAD-CV-MateriaIs].ID WHERE ([CAD-CV-Parts].Width > 40
OR [CAD-CV-Parts].Width > 40
OR [CAD-CV-Cabinets].[Cabinet Type] IN(3))
and dbo.[CAD-CV-Parts].DoorID = 0
AND dbo.[CAD-CV-Parts].DrawerID = 0
AND dbo.[CAD-CV-Parts].RollOutID = 0
AND dbo.[CAD-CV-Parts].TopID = 0 ORDER BY dbo.[CAD-CV-Cabinets].[Cabinet ID] , dbo.[CAD-CV-Parts].AutoID;

at the time of billing ,customer creation screen should opens every time no matter what value is there in database property table

, i am getting customer screen for walkin customer but i am not getting this screen for existing customer,please help me
here is the if condition code
if (customerData[25].equalsIgnoreCase
(Configuration.getParameter(ConfigSetting.CUSTOMER_EDIT_CRITERIA))
|| iCalledfromSearch
|| (Configuration.getParameter(ConfigSetting.CUSTOMER_EDIT_CRITERIA))
.equalsIgnoreCase("NA") )
Need to add one more condition as below
(Configuration.getParameter(ConfigSetting.CUSTOMER_EDIT_CRITERIA))
.equalsIgnoreCase("Y") )

How to delete a sales order which is in sales order status?

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]

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