I defined a button via "Server Actions" in this FORM VIEW:
And created another FORM VIEW from the submenu.
Then I'd tried to call this FORM VIEW via the button, but it's not worked.
So how to call this FORM VIEW via the button?
Please help!
Thank you!
Try to give
"view_mode" : "form"
in xml :
<record id="account_common_report_view" model="ir.ui.view">
<field name="name">Common Report</field>
<field name="model">account.common.report</field>
<field name="arch" type="xml">
<form string="Report Options">
<group col="4">
<header>
<button name="check_report" string="Print" type="object"
default_focus="1" class="oe_highlight"/>
<button string="Cancel" class="btn btn-secondary" />
</header>
</form>
</field>
</record>
python :
call every things call
def check_report(self):
self.ensure_one()
data = {}
data['ids'] = self.env.context.get('active_ids', [])
data['model'] = self.env.context.get('active_model', 'ir.ui.menu')
data['form'] = self.read(['date_from', 'date_to', 'journal_ids', 'target_move', 'company_id'])[0]
used_context = self._build_contexts(data)
data['form']['used_context'] = dict(used_context, lang=get_lang(self.env).code)
return self.with_context(discard_logo_check=True)._print_report(data)
Related
I am trying override base email template(noupdate=1) but, unable to override. Also, search for my issue but didn't get proper solution.
So, anybody can help me for this issue.
my code is like:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="0">
<!-- Email template for reset password -->
<delete id="auth_signup.reset_password_email" model="mail.template"/>
<record id="reset_password_email" model="mail.template">
. . .
</record>
<!-- Email template for new users -->
<delete id="auth_signup.set_password_email" model="mail.template"/>
<record id="set_password_email" model="mail.template">
. . .
</record>
</data>
</odoo>
This error comes when create new user:
ValueError: External ID not found in the system: auth_signup.reset_password_email
Thanks in advance
well, you don't need to override the existing email template. you may need a new one. you could also delete the old one
<record id="reset_password_email" model="mail.template">
<field name="name">Auth Signup: Reset Password</field>
<field name="model_id" ref="base.model_res_users"/>
<field name="subject">Password reset</field>
<field name="email_from">"${object.company_id.name | safe}" <${(object.company_id.email or user.email) | safe}></field>
<field name="email_to">${object.email_formatted | safe}</field>
<field name="body_html" type="html">
<p>whatever email template you want & remember you could use OBJECT AS FOLLOWING</p>
<span style="font-size: 20px; font-weight: bold;">
${object.name}
</span>
</field>
<field name="lang">${object.lang}</field>
<field name="auto_delete" eval="True"/>
<field name="user_signature" eval="False"/>
</record>
please note that you custom template id would be names as custom_module.reset_password_email & it will replace auth_signup.reset_password_email.
or you could follow:
Odoo - How to update non updateable records by XML
i'm trying to print an Odoo custom report based on a wizard.
it takes inputs from a wizard view. The wizard lets the user select a project with start_date and end_date. and click print button. so the list of activities that match the wizard form fields filter should be printed in a PDF. but i got a PDF file with 0 KB and when i try to open i get Format error: Not a PDF or corrupted. and there is no errors in console
Here is some key files
reports/__init__.py
# -*- coding: utf-8 -*-
from odoo import models, api
class ReportWorkPlan(models.AbstractModel):
_name = 'ewonga_pta.report_model_work_plan'
#api.model
def render_html(self, docids, data=None):
docs = self.env['ew.pta.line'].browse(docids)
docargs = {
"doc_ids": docs.ids,
"doc_model": "ew.pta.line",
"docs": docs,
}
return docargs
reports/print_work_plan_template.xml
<?xml version="1.0" ?>
<odoo>
<template id="report_work_plan_template">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="web.external_layout">
<div class="page">
<h2>Report title</h2>
</div>
</t>
</t>
</t>
</template>
</odoo>
reports/work_plan_report.xml
<?xml version="1.0" ?>
<odoo>
<report
id="action_work_plan_print_report"
string="Print Report"
model="ewonga_pta.report_model_work_plan"
report_type="qweb-pdf"
name="ewonga_pta.report_work_plan_template"
file="print_work_plan_template"
/>
</odoo>
wizards/workplan.py
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class WorkPlanWizard(models.TransientModel):
_name = "ewonga_pta.work_plan_wizard"
# attendee_ids = fields.Many2many('res.partner', string="Attendees")
project_id = fields.Many2one("account.analytic.account", domain=[("type_interne", "=", "projet" )])
start_date = fields.Date("Date de début")
end_date = fields.Date("Date de fin")
#api.multi
def check_report(self):
data = {}
data["form"] = self.read(
[
"project_id",
"start_date",
"end_date"
]
)[0]
return self.env.ref("ewonga_pta.action_work_plan_print_report").report_action(self, data=data)
wizards/wizard_work_plan.xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="action_work_plan_wizard_action" model="ir.actions.act_window">
<field name="name">Generate Workplan Report</field>
<field name="res_model">ewonga_pta.work_plan_wizard</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="work_plan_wizard_form_view"/>
<field name="target">new</field>
</record>
<record model="ir.ui.view" id="work_plan_wizard_form_view">
<field name="name">work_plan_wizard.form</field>
<field name="model">ewonga_pta.work_plan_wizard</field>
<field name="arch" type="xml">
<form string="Add Attendees">
<group col="4" colspan="4">
<field name="project_id"/>
<field name="start_date"/>
<field name="end_date"/>
</group>
<group col="4" colspan="4">
<footer>
<button name="check_report" string="Imprimer" type="object" default_focus="1" class="oe_highlight"/>
or
<button string="Annuler" class="oe_link" special="cancel"/>
</footer>
</group>
</form>
</field>
</record>
</odoo>
os: Window 10 x64
python: version 3.6.5
wkhtmltopdf: version 0.12.3.2 (with patched qt)
please help me to solve this issues. Thanks
Try to remove your "data" parameters pass thru "report_action" call. Self already contain datas.
Thanks
I have a redux-form which is used for data entry from the user(in my case the redux-form is used for recording posts in a blog).So,if I want to edit the existing data,then I want that the user will be redirected to the redux-form but the values of that particular post which the user want to edit should be passed along and the input fields in the redux-form should be populated with the existing data of the the post.So,now I am not able to figure out how to pass the data of the post to the redux-form and populate the redux-form from the beginning.My redux-form now has a function which is used in a "Field" from redux-form.The function looks like:
renderField(field) {
return(
<div className="title-design">
<label className="label-design"> {field.label} </label>
<input
type="text"
className="title-input"
{...field.input}
/>
<div className="text-help has-danger">
{field.meta.touched ? field.meta.error : ''}
</div>
</div>
);
}
And in my render method:
render() {
const { handleSubmit } = this.props;
return (
<form onSubmit={handleSubmit(this.onSubmit.bind(this))}>
<Field
label="Title for Post"
name="title"
component={this.renderField}
/>
<Field
label="Post Content"
name="body"
component={this.renderField}
/>
<Field
label="Category"
name="category"
component={this.renderCategory}
/>
<button type="submit" className="btn btn-primary">Submit</button>
<Link to="/">
<button className="cancel-button">Cancel</button>
</Link>
</form>
);
}
}
Also, can I use the same reudx-form which is used to create a new post, or do I have to create a new component only for editing the already existing posts? Can someone please help me with this.
I've customized my sales report to look from this:
To this:
I commented the code section that shows the company information inside external_layout_header view:
<?xml version="1.0"?>
<t t-name="report.external_layout_header">
<div class="header">
<div class="row">
<div class="col-xs-3">
<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % company.logo" style="max-height: 45px;"/>
</div>
<div class="col-xs-9 text-right" style="margin-top:20px;" t-field="company.rml_header1"/>
</div>
<div class="row zero_min_height">
<div class="col-xs-12">
<div style="border-bottom: 1px solid black;"/>
</div>
</div>
<!-- COMMENTED
<div class="row">
<div class="col-xs-3">
<div t-field="company.partner_id" t-field-options="{'widget': 'contact', 'fields': ['address', 'name'], 'no_marker': true}" style="border-bottom: 1px solid black;"/>
</div>
</div>
-->
</div>
</t>
Somehow, I was expecting to reduce the space between the header and the report body. I've been trying out different ways with no luck. There's a similar question in the Odoo forum but that's for v7 with RML (deprecated). I'm using Odoo v8 QWeb report.
Edit 1:
I already tried #Paulo's solution:
But this is not what I'm looking for. I need to gain space by moving the body near the header and not the other way around
Edit 2 (Solution):
As suggested by #Paulo's comment, playing around with the combination of fields margin_top and header_spacing did the trick. I reduced margin_top from 40 to 20 and header_spacing from 35 to 15.
The solution is on the Paper Format: in my case A4.
You have to go to Settings > Technical > Reports > Paper Format > A4
and decrease the Header spacing value
Creating new paper format is the best way for your custom report. If you change default paper format, will have problem for other reports.
Firstly, you need to create xml file for your custom paper format and then declare that paper format in your module_report.xml file.
You can declare just like that:
<record id="new_id" model="ir.actions.report.xml">
<field name="paperformat_id" ref="module.new_paper_format"/>
</record>
I success declare that paper format in my module_report.xml file, please put following sample after your report part:
<record id="YOUR_FORMAT_ID" model="report.paperformat">
<field name="name">YOUR PAPER FORMAT NAME</field>
<field name="default" eval="True" />
<field name="format">A4</field>
<field name="page_height">0</field>
<field name="page_width">0</field>
<field name="orientation">Portrait</field>
<field name="margin_top">20</field>
<field name="margin_bottom">23</field>
<field name="margin_left">7</field>
<field name="margin_right">7</field>
<field name="header_line" eval="False" />
<field name="header_spacing">15</field>
<field name="dpi">90</field>
<field name="report_ids" eval="[(4, ref('YOUR_MODULE.REPORT_ID'))]"></field>
</record>
I have a custom content type, built with dexterity. In the schema (The schema is listed below), I use 'plone.namedfile.field.NamedFile' for attachements/uploads.
I would like to restrict uploads so that only mp3 files can be attached to my content type. What is the best approach for achieving this?
Here is the full schema/model for my content type:
<model xmlns="http://namespaces.plone.org/supermodel/schema">
<schema>
<field name="date" type="zope.schema.Date">
<description />
<title>Date</title>
</field>
<field name="speaker" type="zope.schema.TextLine">
<description />
<title>Speaker</title>
</field>
<field name="service" type="zope.schema.Choice">
<description />
<title>Service</title>
<values>
<element>1st Service</element>
<element>2nd Service</element>
</values>
</field>
<field name="audio_file" type="plone.namedfile.field.NamedFile">
<description />
<title>Audio File</title>
</field>
</schema>
</model>
I shall begin my search here: http://plone.org/products/dexterity/documentation/manual/developer-manual/reference/default-value-validator-adaptors
I've decided to use javascript for my first line of validation.
I've based my solution on information found at <input type="file"> limit selectable files by extensions
Based on the advice my script looks something like this:
$(document).ready( function() {
function checkFile(event) {
var fileElement = document.getElementById("form-widgets-audio_file-input");
var fileExtension = "";
if (fileElement.value.lastIndexOf(".") > 0) {
fileExtension = fileElement.value.substring(fileElement.value.lastIndexOf(".") + 1, fileElement.value.length);
}
if (fileExtension == "mp3") {
return true;
}
else {
alert("You must select a mp3 file for upload");
return false;
}
}
$("form#form").bind("submit",checkFile);
});
This is half the solution, next I'll need to add validation on the server side.