I would like to print a report from wizard. In this wizard I recover the order selected and call to report_action function with the orders selected.
The problem is that I don't know how to send the orders to this function. This is the code:
def _get_default_orders(self):
return self.env['sale.order'].browse(self.env.context.get('active_ids'))
order_ids = fields.Many2many('sale.order', string='Orders', default=_get_default_orders)
#api.multi
def processed_orders(self):
list = []
for orders in self:
if orders.order_ids:
list.append(orders)
datas = {
'ids': list,
'model': 'sale.order',
}
return self.env.ref('aloha_reports_templates.custom_report_sale_order').sudo().report_action(self, data=datas)
Odoo generate an error because I don't send properly the parameters to the report_action.
Can someone help me?
Thanks
As per your example first, in your system, there is must be aloha_reports_templates.custom_report_sale_order action available for the report.
Let me show you an example from odoo 11 community code
File: account/models/account_invoice.py method(invoice_print)
#api.multi
def invoice_print(self):
""" Print the invoice and mark it as sent, so that we can see more
easily the next step of the workflow
"""
self.ensure_one()
self.sent = True
if self.user_has_groups('account.group_account_invoice'):
return self.env.ref('account.account_invoices').report_action(self)
else:
return self.env.ref('account.account_invoices_without_payment').report_action(self)
As per above code in odoo 11 community there is already account_invoices report action already created as below (account/views/account_report.xml).
<report
id="account_invoices"
model="account.invoice"
string="Invoices"
report_type="qweb-pdf"
name="account.report_invoice_with_payments"
file="account.report_invoice_with_payments"
attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
print_report_name="(object._get_printed_report_name())"
groups="account.group_account_invoice"
/>
Hope this helps!
Related
I've been making this pp size machine, which is somewhat like dank memer's one
#client.command()
async def pp(ctx,member : discord.Member):
size=random.randint(1,10)
message = "8"
for x in range (size):
message= message + "="
if x == size-1:
message = message + "D"
if member == "PROTATO#6826":
message = "8D"
ppsize = discord.Embed(color=discord.Colour.orange(), title=f"PP size",description=f"""{member}'s penis
{message} """)
await ctx.send(embed = ppsize)
But i want to rig the command for a certain user to only show "8D" instead of the random lengths.
But no matter what it is the
if member == "PROTATO#6826":
message = "8D"
code doesnt run or gets over looked?
Can someone help me out with this?
You can check if the member mentioned has the same id as a specific user. You can either enable developer mode on discord, or you can print the member.id at the very beginning. Do view a code example below.
#client.command()
async def pp(ctx, member: discord.Member):
print(member.id) # this would print a user's unique id
message = "Hey!"
if member.id == 394506589350002688: # replace this id with what was printed at the start
message = "Hello!"
await ctx.send(message)
Similar Questions:
How to check if message was sent by certain user? - SO
How do I detect if the message is sent by a specific user id? - SO
I recently got helped for doing a voice time tracking in python for my Discord bot and everything works fine except 1 thing.
Here's my code:
#commands.Cog.listener()
async def on_voice_state_update(self, member, before, after):
if member.bot: #checking this before anything else will reduce unneeded file operations etc
return
with open('data/voice_leaderboard.json', 'r') as file:
voice_data = json.load(file)
new_user = str(member.id)
guild_id = str(member.guild.id)
if new_user not in voice_data[guild_id]: #this adds a new user to the guild dict if they're not in it yet
voice_data[guild_id][new_user] = {
"total_time" : 0,
"join_time" : None}
userdata = voice_data[guild_id][new_user] #this is to make the next code clearer, adding things to this dict also adds them to the voice_data dict, it just make the code "cleaner"
#after making sure the user exists you gotta check if they're joining or leaving a vc(and reject all the other options), plus if they change vc within the same guild it should keep counting. There's multiple ways to do this
if(before.channel == None): #this is when they join a vc (they werent in one before so they gotta have just joined one)
join_time = round(time.time())
userdata["join_time"] = join_time
elif(before.channel.guild == after.channel.guild): #wrote this to only check if they changed vc within the same guild, but then I realised it can also catch all the mute/deafen events yay.
return
elif(str(after.channel.guild.id) != guild_id): #this will check if the channel they're in after the event (we wanna record the time passed if its None or a different guild, both of which will get triggered by this)
if(userdata["join_time"] == None): return #this will catch errors, if they were to happen
userdata = voice_data[guild_id][new_user]
leave_time = time.time()
passed_time = leave_time - userdata["join_time"]
userdata[total_time] += passed_time
userdata["join_time"] = None #preventive measure against errors
with open('data/voice_leaderboard.json', 'w') as update_user_data:
json.dump(voice_data, update_user_data, indent=4)
I get this error when I disconnect:
elif(before.channel.guild == after.channel.guild):
AttributeError: 'NoneType' object has no attribute 'guild'
Anyone know how to fix this?
after.channel is None because the user is not connected to a channel after disconnecting.
You will have to cater for cases like this.
...
elif after.channel is None:
return
elif(before.channel.guild == after.channel.guild):
return
...
How to get the JIRA ticket number using Jenkins Pipeline script Example:
CICD-34
The following command gives complete info about the ticket, but how do we get just the ID and store in a variable?
def issue = jiraJqlSearch jql: 'PROJECT = CICD AND description~"New JIRA Created from Jenkins through Declarative PL script"', site: 'MyLocalJira'”
echo issue.data.toString()
I have the same problem and find a solution.
I share with you my answer :)
def testExecutionSearch = jiraJqlSearch jql: "project=${project} and issuetype = 'Test Execution' and summary ~ '${summary}'", site: 'myjira', failOnError: true
if (testExecutionSearch != null){
//Get all issues
def issues = testExecutionSearch.data.issues
//Get the key of the first result
def key = issues[0].key
}
Here I take the first element of my jql search (def key = issues[0].key) but you can choose what you want :)
I'm doing an automation in Ruby and Appium on mobile, and I need to access a card that is out of range, and I'm using all possible methods and it just happens error ... Does anyone have a solution? I need to down the Recycler view all the way down
Edit:
code
class AuditoriaController
def initialize
#util = UtilMethods.new
#objects = PageAuditoria.new
main = MenuPrincipal.new
#menus = main.menus
#tela_principal = main.tela_principal
#objects_auditoria = #objects.tela_auditoria
end
def acessar_auditoria
data_sync = find_element(:xpath, #tela_principal[:msg_sincronizacao]).text
data_sync.slice!("Última atualização: ")
t = Time.now
while(t.strftime("%d/%m/%Y %H:%M:%S") != data_sync)
btn_sync = find_element(:xpath, #tela_principal[:view_sync])
btn_sync.click
break;
end
list = find_element(:xpath, #tela_principal[:lista])
list.scrollIntoView()
#menu_auditoria = find_element(:xpath, #menus[:menu_auditoria])
#if(menu_auditoria)
# #util.logger("ACHEI AUDITORIA")
#end
end
First get the element(that is card)
Then add the below code
browser.execute_script('arguments[0].scrollIntoView();', card);
Hope it will help you. If you need any more information just comment here
EDIT:
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.execute_script('arguments[0].scrollIntoView();', card)
Here driver is the driver you are using for automation that is appium driver. Here card is the element that you want to get and scroll upto it.
In ruby:
def scroll_to_element(element)
#driverAppium.execute_script('mobile: scroll', name: element.name)
end
This will scroll to the element which you are looking for even if it is offscreen. You should be able to modify for use with Java.
scroll_to_exact(elementname) should do the job for you! This will scroll to through the elements until the specified is visible. This is in Appium_lib for ruby
I'm getting started with Google App Engine. I want to make an AJAX chat.
class ChatMessage(db.Model):
message = db.StringProperty()
created = db.DateTimeProperty(auto_now_add=True)
class RPCHandler(webapp.RequestHandler):
##get message every 4 seconds
def get(self):
que = db.Query(ChatMessage).order('-created')
chat_list = que.fetch(limit=3)
jencoded_chat_list = gaejsonEncoder.encode(chat_list) ##my own module
self.response.out.write(jencoded_chat_list)
RESULT: message3,message2,message1
This is what I intended.
I wanted to add POST ajax Request, so added RPCHandler2.
class RPCHandler2(webapp.RequestHandler):
def post(self):
msg = self.request.get('message')
if msg == '':
return
newchat = ChatMessage(message=msg)
newchat.put()
que = db.Query(ChatMessage).order('-created')
chat_list = que.fetch(limit=3))
jencoded_chat_list = gaejsonEncoder.encode(chat_list)
self.response.out.write(jencoded_chat_list)
I write "POST Message!" in textarea and click the button,
RESULT: POST Message!,message3,message2
This is what I wanted.
But 4 seconds later, 'GET' started and
RESULT: message3,message2,message1
Why 'GET' couldn't get the new message from datastore?
Thanks in advance.
If you are using the high replication datastore you might be facing an "eventual consistency" problem. The datastore replica handling the get request may not have received the recently submitted data yet.
If you put the newchat.put() inside of a transaction it's more likely that future gets will be consistent.