openerp 7: report not showing up - reporting

I created a report record via the interface but it doesn't show up in the print dropdown.
In settings -> actions -> reports, I added a new record:
Name: My Test
Service Name: my_po_reports
Object: purchase.order
Report Type: pdf
Report file: purchase/report/order.rml (i'm reusing an existing one just to test)
But My Test does NOT show up when I go to purchase order form!
I also tried the same in aeroo reports without any result:
In settings -> actions -> aeroo reports -> reports, I added a new record:
Name: My Test
Service Name: my_po_report
Object: purchase.order
Template type: odt Output type: odt
Template source: file Template path: myfolder/reports/template.odt
What am I missing?
Thanks

As you define actions for rml report. You have to also define one record for this report in action binding.
Settings ==> Actions ===> Action Bindings
Name : Purchase Order (Report Name to display)
Model Name: purchase.order (here your model)
Qualifier : client_print_multi
Action Reference : ir.actions.report.xml,360 (your report xml id here)
Hope this helpful to you
Regards,

EDIT: replacing my earlier solution with the following as this does not require an uninstall and reinstall:
<record id="report_mypo_test" model="ir.actions.report.xml">
<field name="name">Stock Moves Report</field>
<field name="type">ir.actions.report.xml</field>
<field name="model">stock.move</field>
<field name="report_name">mypo.test</field>
<field name="report_type">aeroo</field>
<field name="in_format">oo-odt</field>
<field name="out_format" model="report.mimetypes" ref="report_aeroo.report_mimetypes_odt_odt"/>
<field name="parser_loc">myaddon/reports/my_parser.py</field>
<field name="report_rml">myaddon/reports/template.odt</field>
<field name="parser_state">loc</field>
<field name="tml_source">file</field>
</record>
<report auto="False" menu="True" id="report_mypo_test" model="stock.move"
name="mypo.test" rml="myaddon/reports/template.odt" string="Stock Moves Report"/>
my_parser.py:
import time
from tools.translate import _
from report import report_sxw
from report.report_sxw import rml_parse
from osv import fields, osv
import netsvc
class Parser(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(Parser, self).__init__(cr, uid, name, context)
ids = self.pool.get('stock.move').search(self.cr, self.uid, [], context=context)
self.stockmoves = self.pool.get('stock.move').browse(self.cr, self.uid, ids)
self.localcontext.update({
'stockmoves': self.stockmoves
})
Credit to God Almighty, and many people who contribute their work on the internet.

Related

Odoo duplicate many2many fields

A model [m] with a many2many field [m2m]
Field [m2m] have attribute [copy=False]
A form view [v] display the [m] and the field [m2m] with widget [many2many_tags]
I have tested that the python object did return a with False on field [m2m]
but the javascript, keep render the tags on web.
model.py
class model(models.Model):
_name = "m"
m2m = fields.Many2many('sale.order', string="SO", copy=False)
XML File
<record ...>
<form>
<group>
<field name="name"/>
<field name="ref"/>
<field name="so_m2m" widget="many2many_tags" options="{'no_create_edit': True}"/>
</group>
</form>
</record>
When I duplicate the current record, the field [m2m] is keeps the old tag from old record which is not expected.
After clicking the save button, the old tag will disappear.
Try one thing here :
Whatever your third table is there, both fields used in many2many relation, from third table keep them as a copy false.
i.e.
m2m = fields.Many2many('sale.order','sale_order_another_table_rel', 'sale_order_field','antother_table_field', string="SO", copy=False)
Into new table :
_name = 'sale.order.another.table.rel'
sale_order_field_id = // copy=false
another_table_field_id = //copy = false
Hopefully work.

Odoo 8 strange behavious using new api to inherit old api model

I added two fields to stock.picking using new api:
class StockPicking(models.Model):
_inherit = "stock.picking"
address = fields.Char(related='partner_id.street', string="Address")
sector = fields.Char(related="partner_id.sector", string="Sector")
Then I added onchange method to load stock pickings in One2Many field defined using tree:
<field name="line_ids" >
<tree>
<field name="name" />
<field name="partner_id" />
<field name="address"/>
<field name="sector"/>
<field name="state" />
</tree>
</field>
I used a simple domain with search [('id', '<', '10')] then I changed line_ids value but no line was loaded in the web view.
After many times trying to find a log error with no success I changed the code from the new API to the old API:
class StockPicking(osv.osv):
_inherit = "stock.picking"
_columns = {
'address': fields.related('partner_id', 'street', type='char', relation='res.partner', string='Address'),
'sector': fields.related('partner_id', 'sector', type='many2one', relation='sector', string='Sector')
}
For a reason that I do not know It worked.
Did someone know why this did not work using the new API?

Odoo 9.0 C How to add a new many2one field from an inherited view?

Could you guy please show me what is the right steps to follow when we want to add a new many2one field to an inherited view like account.invoice.order.
It's like the same :
<template id="new_id" inherit_id="module_name.qweb_template_id" name="Template name as you want">
<!-- specify the target that you want to add the many2one field
than the place after,before or inside -->
<xpath expr="//target_where_you_want_to_add" position="after/before/inside">
<field name="your_one_to_many_field_name" />
</xpath>
</template>
the hard part is targeting the write place
like if you want to add the the field to a div tag inside a div with id ="div_id" and the div contain a class="class_name"
<xpath expr="//div[#id='div_id']/div[#class='class_name']" position="inside">
or a after a field inside that div named field1
<xpath expr="//div[#id='div_id']/div[#class='class_name']/field[#name='field1']" position="after">
or after a field that named field1
<!-- // is like a shortcut -->
<xpath expr="//field[#name='field1']" position="after">
so see who can you target the place that you want to put the field using tag names and properties like id,class,... (string is not supported in odoo 9)

Unable to use related field in domain filter

Field declaration in odoo v8, team_manager is a new class:
class team_manager(osv.osv):
_name = "team.manager"
_columns = {
'is_manager': fields.related('manager_id', 'manager', type='boolean', relation="hr.employee", string='Managers', readonly=True, store=True)
}
The xml file code for 'Form View'
<separator string="Team Work" attrs="{'invisible':[('is_manager','=',False)]}"/>
<field name="child_line" context="{'manager_id':id}" attrs="{'invisible':[('is_manager','=',False)]}">
<tree editable="=top">
<field name="employee_id"/>...
</tree>
</field>
While opening the form I am getting the error like
Odoo Client Error
Error: Unknown field is_manager in domain [["is_manager","=",false]]
http://localhost:8069/web/static/src/js/view_form.js:1702
Can't we use related filed in domain? or Does my syntax need changes?
You need to add is_manager field to the form view.
Add the following line before child_line field:
<field name="is_manager" invisible="True"/>

How do you add fields to com_content in Joomla! with a plugin and store the data in its own table?

I'm running Joomla 1.7 and I know that it has the ability to add custom form fields to components with a plugin.
There is a sample plugin located at:
/plugins/user/profile
This plugin allows you to put custom form fields on the user profile front end and back end and these fields are stored in a custom table.
I created a similar plugin for user profiles and it worked perfectly.
However, when I go to create a plugin like this for com_content, I am met with a problem.
this is what my XML file looks like:
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="additionalinfo">
<fieldset name="additionalinfo_fieldset" label="PLG_CONTENT_ADDITIONALINFO_FIELDSET_LABEL">
<field name="tagline" type="text" size="50" default="" label="PLG_CONTENT_ADDITIONALINFO_TAGLINE_LABEL" description="PLG_CONTENT_ADDITIONALINFO_TAGLINE_DESC" />
<field name="pseudocategory" type="category" extension="com_content" label="PLG_CONTENT_ADDITIONALINFO_PSEUDOCATEGORY_FIELD_LABEL" description="PLG_CONTENT_ADDITIONALINFO_PSEUDOCATEGORY_FIELD_DESC" />
</fieldset>
</fields>
</form>
This however does not work, whenever I do something like above, the form fields never show up on the admin form (even though I have it set correctly, and the only thing that changed between the user plugin and the content plugin is the name of the form i'd like the form to appear on
When I change my XML to this:
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="attribs">
<fieldset name="additionalinfo_fieldset" label="PLG_CONTENT_ADDITIONALINFO_FIELDSET_LABEL">
<field name="tagline" type="text" size="50" default="" label="PLG_CONTENT_ADDITIONALINFO_TAGLINE_LABEL" description="PLG_CONTENT_ADDITIONALINFO_TAGLINE_DESC" />
<field name="pseudocategory" type="category" extension="com_content" label="PLG_CONTENT_ADDITIONALINFO_PSEUDOCATEGORY_FIELD_LABEL" description="PLG_CONTENT_ADDITIONALINFO_PSEUDOCATEGORY_FIELD_DESC" />
</fieldset>
</fields>
</form>
When I make this simple change, the form fields show up! BUT, the data isn't stored or retrieved from the custom table, it just goes into the 'attribs' column on the _content table. This stores the content in JSON, which is alright, but we'd like to be able to index the content by the custom fields (and not have to loop through each record in the database to find what we're looking for).
Any ideas on how to fix this?
thanks!
david barratt
I guess your plugin file ( for example, "yourplugin.php" ) will have one method called "onContentPrepareForm". If you want to add data to an article, this method should start like this:
function onContentPrepareForm($form, $data)
{
if (!($form instanceof JForm))
{
$this->_subject->setError('JERROR_NOT_A_FORM');
return false;
}
// Check we're manipulating an
if ( $form->getName() != "com_content.article" ) {
return true;
}
//[...] The rest of your code here
Besides, if you want to store these fields in another table in order to make it easier to search using this fields, maybe you should create a new table and save the data using the "onContentAfterSave" method:
public function onContentAfterSave( $context, &$article, $isNew )
On this method, you should always check that $context is "com_content.article", otherwise you might face problems when saving categories.
I hope it helps!

Resources