Unable to use related field in domain filter - odoo-8

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"/>

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?

How to Display linqxml list data to datatable

I have an xml like this
<?xml version="1.0" encoding="utf-8"?>
<content>
<field title="Year">
<description>Numeric data</description>
<comment>1234</comment>
</field>
<field title="mail">
<description>Numeric data</description>
<comment>ABCD</comment>
</field>
<field title="Year">
<description>AlphNumeric Data</description>
<comment>ABCD1234</comment>
</field>
</content>
i tried below linq query to extract data based on the title attribute.
var Data = XDocument.Load(Xmlpath).Root
.Descendants("field")
.Where(element => element.Attribute("title").Value.Contains("Year"))
.Descendants()
.Where(element => element.Name == "description" || element.Name == "comment")
.Select(element => new { element.Name, element.Value }).ToList();
for eg i want to show all datas that comes under title "year", the output should be displayed into a datatable like this
Description Comment
numeric data 1234
Alphanumeric Data ABCD1234
But i dont know how to convert var data to datatable or iterarte though var data .Can somebody help me? is it possible to display the result from linq query by modifying the query itself?
DataTable's have a method (ReadXml) that reads XML. Have you tried using that?

OpenERP, dynamic DOMAIN in view

I work with OpenERP and I try to create a new form view for the account_bank_statement_line object. so when i create a new statement line the statement object must in open state so far no problem i solved with domain in the field tag attribute, But when I try to view the satatement after confirming the cash; the statement_id will desapear becouse it state is confirmed how can I solve this probleme can sommeone help me
<field colspan="2" name="statement_id" domain="[('state','=','open')]" attrs="{'readonly':[('state','=', 'confirm')]}" widget="selection" string="Cash Register"/>
<field colspan="6" name="amount" attrs="{'readonly':[('state','=', 'confirm')]}" />
regards
try adding the domain, domain="[('state','in',['open','confirm'])]"
From your code I don't really see what is hiding your field "statement_id". The fields are visible by default and can be hidden by the invisible attribute. Try to add it explicitly to your field definition:
<field colspan="2" name="statement_id"
invisible="0"
domain="[('state','=','open')]"
attrs="{'readonly':[('state','=', 'confirm')]}"
widget="selection" string="Cash Register"/>

openerp 7: report not showing up

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.

Resources