can you please help me regarding close wizard.
i have created a wizard from xml when i add dates and click on xlsx button,
xlsx generated and wizard close it self. it works fine.
but when i click on pdf, pdf generate successfully but wizard remains open.
how can i close it.
here is my code of xml.
<record id="payment_invoice_wizard_form" model="ir.ui.view">
<field name="name">Invoice Payment Report</field>
<field name="model">invoice.payment_report</field>
<field name="arch" type="xml">
<form string="Invoice Payment Report">
<group>
<field name="start_date"/>
<field name="end_date"/>
<field name="status"/>
</group>
<!-- other fields -->
<footer>
<button name="print_pdf" string="Print" type="object" class="btn-primary"/>
<button name="print_xls" string="Print in XLS" type="object" class="btn-primary"/>
<button string="Cancel" class="btn-default" special="cancel" />
</footer>
</form>
</field>
</record>
on py side i am getting all necessary data and returning this function
#api.multi
def print_pdf(self):
#mycode
return self.env.ref('customer_products.pdf_products').report_action(self)
When Odoo launch the download action of a report it will check if close_on_report_download action attribute is set to true, if so it will return action of type ir.actions.act_window_close which will close the wizard.
#api.multi
def print_pdf(self):
action = self.env.ref('customer_products.pdf_products').report_action(self)
action.update({'close_on_report_download': True})
return action
Edit:
You can implement the same logic, override QWEBActionManager and check if the option is passed through the action definition and if yes close the window.
var ActionManager = require('web.ActionManager');
var session = require('web.session');
ActionManager.include({
ir_actions_report: function (action, options) {
var self = this;
return $.when(this._super.apply(this, arguments), session.is_bound).then(function() {
if (action && action.report_type === 'qweb-pdf' && action.close_on_report_download) {
return self.do_action({ type: 'ir.actions.act_window_close' });
}
});
},
});
Related
i have created a button "+Add Products" below order lines using inheritance and xpath in sale.order in Odoo 13.0 Sales Module, my aim is that when i click "+Add Products" button, Just open a wizard (like customized form view, where i can fill products details) and also create below Add button in wizard.
quotation_product.xml
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record model="ir.ui.view" id="view_order_form">
<field name="name">sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="/form/sheet/notebook/page/field[#name='order_line']"
position="before">
<button name="my_button" string=" + Add Products" type="object" class="btn
btn-info btn- lg"/>
</xpath>
</field>
</record>
</data>
</odoo>
quotation_product.py
from odoo import api, fields, models, api
class SaleOrder(models.Model):
_inherit = "sale.order"
_name = "sale.order"
def my_button(self, context=None):
print("ghghhhghghghghg")
return True
Mr op,
On your button, you can return your view like this,
So pass the object and your module view.In that, your view added the button on footer and with same added the logic on that footer_button to perform in your customized way.
def my_button(self):
return {
'name': "Your String",
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'object',
'view_id': self.env.ref('module.view_id').id,
'target': 'new'
}
And In your py file if you want to inherit the odoo defaul_object like sale.order then no need to use the _name.
class SaleOrder(models.Model):
_inherit = "sale.order"
You can also refer and find the official odoo13 documentation.
Thanks
I have added a menu item in Reporting Tab in Manufacturing module. I have already written python code to create CSV file. But unable to figure out how to make it downloadable when I click the menu item in manufacturing module.
Here is the menu item code:
<record model="ir.actions.server" id="raw_material_planning">
<field name="name">Raw Material Planning</field>
<field name="type">ir.actions.server</field>
<field name="res_model">gear.manufacturing</field>
<field name="model_id">342</field>
<field name="state">code</field>
<field name="code">
action = model.raw_material_planning()
</field>
</record>
<menuitem name="Raw Material Planning" parent="mrp.menu_mrp_reporting" id="menu_raw_material_planning"
action="raw_material_planning"/>
Also, it should directly download and not go to any window.
UPDATE
saved dictionary to CSV file
files = base64.b64encode(open('test.csv','rb').read())
attachment = self.env['ir.attachment'].create({
'name': 'test.csv',
'datas': files,
'datas_fname': 'test.csv'
})
return {
'type': 'ir.actions.act_url',
'url': '/web/content/%s?download=true' % (attachment.id),
# 'target': 'new',
'nodestroy': False,
}
Kindly assist me
Here is all controllers are available for download contents or files.
You need to return any of controller with your file content it will automatically download.
[
'/web/content',
'/web/content/<string:xmlid>',
'/web/content/<string:xmlid>/<string:filename>',
'/web/content/<int:id>',
'/web/content/<int:id>/<string:filename>',
'/web/content/<int:id>-<string:unique>',
'/web/content/<int:id>-<string:unique>/<string:filename>',
'/web/content/<string:model>/<int:id>/<string:field>',
'/web/content/<string:model>/<int:id>/<string:field>/<string:filename>'
]
For download any file you need to create one attachment record for ir.attachment.
Then just add below code in your function for return file to url.
attachment = self.env['ir.attachment'].search([('name', '=', 'import_product_sample')])
return {
'type': 'ir.actions.act_url',
'url': '/web/content/%s?download=true' % (attachment.id),
'target': 'new',
'nodestroy': False,
}
It will automatically download your file in browser.
In Odoo, I inherited the "project" model and made some small changes.
Project model in my module:
class project(models.Model):
_inherit = "project.project"
_columns = {
'is_project' : fields.boolean("Is project", default=True)
}
class project_task_type(models.Model):
_inherit = "project.task.type"
_columns = {
'task_type_is_project' : fields.boolean("Is project", default=True)
}
Relation beetwen project_project and project_task_type in original project module:
project_project:
'type_ids': fields.many2many(
'project.task.type', 'project_task_type_rel', 'project_id',
'type_id', 'Tasks Stages',
states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}),
project_task_type:
'project_ids': fields.many2many(
'project.project', 'project_task_type_rel',
'type_id', 'project_id', 'Projects'),
In original form view :
<record id="edit_project" model="ir.ui.view">
<field name="name">project.project.form</field>
<field name="model">project.project</field>
<field eval="2" name="priority"/>
<field name="arch" type="xml">
[...]
<page string="Project Stages" attrs="{'invisible': [('use_tasks', '=', False)]}" name="project_stages">
<field name="type_ids"/>
</page>
[...]
So my question is how to filter type_ids records to get values from project_task_type where task_type_is_project = False.
I added domain attribute to field with name "type_ids"
<field name="type_ids domain="[('type_id.task_type_is_poject','=',False)]"/>
<field name="type_ids domain="[('task_type_is_poject','=',False)]"/>
but without success.
I will be very grateful for any help.
I added domain attribute to field with name "type_ids"
<field name="type_ids domain="[('type_id.task_type_is_poject','=',False)]"/>
<field name="type_ids domain="[('task_type_is_poject','=',False)]"/>
but without success.
The second way is the correct one, the domain operates on the model of the field, so project.task.type, which means you should directly filter on its fields, in this case task_type_is_project. There is no type_id field.
The only problem I see is a typo: you forgot a r in project.
I have installed meteor-typeahead via npm. https://www.npmjs.org/package/meteor-typeahead
I have also installed
meteor add sergeyt:typeahead
from https://atmospherejs.com/sergeyt/typeahead
I am trying to get the data-source attribute example to function so I can display a list of countries when the user begins to type. I have inserted all countries into the collection :-
Country = new Meteor.Collection('country');
The collection is published and subscribed.
When I type into the input field, no suggestions appear. Is it something to do with activating the API? if so how do I do this? Please reference the website https://www.npmjs.org/package/meteor-typeahead
My form looks like this:
<template name="createpost">
<form class="form-horizontal" role="form" id="createpost">
<input class="form-control typeahead" name="country" type="text" placeholder="Country" autocomplete="off" spellcheck="off" data-source="country"/>
<input type="submit" value="post">
</form>
</template>
client.js
Template.createpost.helpers({
country: function(){
return Country.find().fetch().map(function(it){ return it.name; });
} });
In order to make your input to have typeahead completion you need:
Activate typeahead jQuery plugin using package API
Meteor.typeahead call in template rendered event handler.
Meteor.typeahead.inject call to activate typeahead plugin for elementes matched by CSS selector available on the page (see demo app).
Write 'data-source' function in your template understandable by typeahead plugin. It seems your 'data-source' function is correct.
Add CSS styles for typeahead input(s)/dropdown to your application. See example here in demo app.
Try this way in your template:
<input type="text" name="country" data-source="country"
data-template="country" data-value-key="name" data-select="selected">
Create template like country.html (for example /client/templates/country.html) which contains:
<template name="country">
<p>{{name}}</p>
</template>
In your client javascript:
Template.createpost.rendered = function() {
Meteor.typeahead.inject();
}
and
Template.createpost.helpers({
country: function() {
return Country.find().fetch().map(function(it){
return {name: it.name};
});
},
selected: function(event, suggestion, datasetName) {
console.log(suggestion); //or anything what you want after selection
}
})
I'm trying to create a custom field type in SharePoint (WSS 3.0) that has custom properties. I have created my fldtypes*.xml file based on the SDK docs and this blog post and it seems to render fine and I can retrieve the custom property values inside my code. My problem is that after the initial field creation, if I go back to the list settings page and click on my newly added field, the form shows my custom properties with some value that I'm not providing it. For example, if my custom property's display name is "My Custom Prop" then the value in its textbox will be "My Custom Prop field value".
My question is this: how can I properly show the actual string values of my custom property types in these textboxes?
Here's my fldtypes*.xml file:
<?xml version="1.0" encoding="utf-8"?>
<FieldTypes>
<FieldType>
<Field Name="TypeName">MyCustomField</Field>
<Field Name="TypeDisplayName">My Custom Field</Field>
<Field Name="TypeShortDescription">MyCustomField</Field>
<Field Name="ParentType">Text</Field>
<Field Name="UserCreatable">TRUE</Field>
<Field Name="FieldTypeClass">MyCustomField.CustomFields.MyCustomField, MyCustomField, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d772gbab82fe6996</Field>
<PropertySchema>
<Fields>
<Field Name="MyCustomProp" DisplayName="My Custom Prop" Type="Text" MaxLength="50" DisplaySize="30" />
</Fields>
</PropertySchema>
</FieldType>
</FieldTypes>
And here's the code for my field type class:
public class MyCustomField : SPFieldText
{
private string propval;
public MyCustomField(SPFieldCollection fields, string fieldName)
: base(fields, fieldName)
{
}
public MyCustomField(SPFieldCollection fields, string typeName, string displayName)
: base(fields, typeName, displayName)
{
}
public override void Update()
{
// I can see any updated value here
propval = GetCustomProperty("MyCustomProp") as string;
base.Update();
}
public override Type FieldValueType
{
get { return typeof (string); }
}
}
What can I do to see the correct custom property values in my "Change Column" page (FldEditEx.aspx) in my SharePoint app?
There is a well known issue with saving and retrieving custom properties on a custom field type. Here is a direct link to the work around.
btw, some of the comments on the post purport the same problem.