How set data from a name in a many2many - odoo-14

I got a many2many value which is "Field service" in 'project.project' model, I want to set it in the new data value in 'project.task.type' model.
this is what I've start to do :
<record id="project_task_type_annule" model="project.task.type">
<field name="name">Annulé</field>
<field name="sequence">54</field>
<field name="is_closed">False</field>
</record>
And I want to do :
<record id="project_task_type_annule" model="project.task.type">
<field name="name">Annulé</field>
<field name="sequence">54</field>
<field name="is_closed">False</field>
<field name="project_ids" eval="[(6,0,[ref(project.project.search({'name':'Field Service'}) )] )]" />
</record>

Related

Why many2one field in one2many is a littlte spacing odoo13

I have 13 column in my one2many field and I can't reduce cause of requirement. The problem is my many2one column is very less space. When I remove some column , many2one field take perfect column width.But I can't reduce. How can I do that? I try to write css class for my tree view but not working.In image, I can only see Ac text but the really name is Account.
<page string="Yearly Budget">
<field name="budget_yearly_line">
<tree string="Yearly" editable="buttom" class="custom_class">
<field name="account_id"/>
<field name="jan"/>
<field name="feb"/>
<field name="march"/>
<field name="april"/>
<field name="may"/>
<field name="june"/>
<field name="july"/>
<field name="auguest"/>
<field name="sep"/>
<field name="october"/>
<field name="november"/>
<field name="dec"/>
<field name="amount"/>
</tree>
</field>
<group class="oe_subtotal_footer oe_right">
<field name="amount_untaxed"/>
</group>
</page>

Create two graph view for one model openerp

I want Create two graph view for one model openerp, I like to define Two menu for each one display a graph view,
exemple one content graph by country the ather by gender
You need to create two graph view in xml.
<record id="country_graph_id" model="ir.ui.view">
<field name="name">country.graph</field>
<field name="model">your.model</field>
<field name="arch" type="xml">
<graph string="By Country" type="bar">
<field name="your fields"/>
<field name="your_field2"/>
</graph>
</field>
</record>
<record id="country_gender_id" model="ir.ui.view">
<field name="name">gender.graph</field>
<field name="model">your.model</field>
<field name="arch" type="xml">
<graph string="By Gender" type="bar">
<field name="your_field3"/>
<field name="your_field4"/>
</graph>
</field>
</record>
after that, you need to create two actions and two menus like,
<record id="action_for_country_graph" model="ir.actions.act_window">
<field name="name">By Country</field>
<field name="res_model">your.model</field>
<field name="view_type">form</field>
<field name="view_mode">graph</field>
<field name="view_id" ref="country_graph_id"/>
</record>
<record id="action_for_gender_graph" model="ir.actions.act_window">
<field name="name">By gender</field>
<field name="res_model">your.model</field>
<field name="view_type">form</field>
<field name="view_mode">graph</field>
<field name="view_id" ref="gender_graph_id"/>
</record>
<menuitem action="action_for_country_graph" id="menu_country_graph_id"
sequence="1" name='Country Graph' parent='parent.menu'/>
<menuitem action="action_for_gender_graph" id="menu_gender_graph_id"
sequence="2" name='Gender Graph' parent='parent.menu'/>

OpenERP - implementing something similar to stock.picking.in

The way stock.picking.in is implemented in openERP is interesting. I am trying to do something similar with purchase orders.
Stock.picking.in inherits from stock.picking, customizes a few columns and defaults and declares the table as stock_picking. On the UI side, a form view is inherited from view_picking_form and the model used is stock.picking.in.
I am trying to do something similar by creating a special purchase order. The problem is that the form for the special PO never gets picked up. It always shows a dynamic view with all fields of the PO dumped in some default manner. The developer mode also does not show the right form view.
When I check Settings -> User Interface -> Views, it does show the view properly but doesn't display it when I create new special PO.
Here is the code:
class my_purchase_order(osv.osv):
_name = "purchase.order"
_inherit = "purchase.order"
_columns={
...
}
my_purchase_order()
class my_purchase_order_special(osv.osv):
_name = 'purchase.order.my_special'
_inherit = "purchase.order"
_table = "purchase_order"
_columns = {...
}
my_purchase_order_special()
<record id="po_my_special_form" model="ir.ui.view">
<field name="name">po_my_special_form</field>
<field name="model">purchase.order.my_special</field>
<field name="type">form</field>
<field name="inherit_id" ref="purchase.purchase_order_form" />
<field name="arch" type="xml">
...
</field>
</record>
<record id="po_my_special_tree" model="ir.ui.view">
<field name="name">po_my_special_tree</field>
<field name="model">purchase.order.my_special</field>
<field name="arch" type="xml">
<tree fonts="bold:message_unread==True" colors="grey:state=='cancel';blue:state in ('wait','confirmed');red:state in ('except_invoice','except_picking')" string="Purchase Order">
<field name="message_unread" invisible="1"/>
<field name="name" string="Reference"/>
<field name="date_order" />
<field name="partner_id"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
<field name="minimum_planned_date" invisible="context.get('quotation_only', False)"/>
<field name="origin"/>
<field name="amount_untaxed" sum="Total Untaxed amount" string="Untaxed"/>
<field name="amount_total" sum="Total amount"/>
<field name="state"/>
</tree>
</field>
</record>
<record id="action_po_my_special_tree" model="ir.actions.act_window">
<field name="name">Special Purchase Orders</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">purchase.order.my_special</field>
<field name="view_mode">tree,form,graph,calendar</field>
<field name="context">{}</field>
<field name="domain">[('state','=','draft')]</field>
<field name="search_view_id" ref="purchase.view_purchase_order_filter"/>
</record>
<record id="action_po_my_special_form" model="ir.actions.act_window.view">
<field eval="2" name="sequence"/>
<field name="view_mode">form</field>
<field name="view_id" ref="po_my_special_form"/>
<field name="act_window_id" ref="action_po_my_special_tree"/>
</record>
Please advise. Thanks in advance.
Turns out I was missing view records:
<record id="action_po_my_special_tree2" model="ir.actions.act_window.view">
<field eval="1" name="sequence"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="po_my_special_tree"/>
<field name="act_window_id" ref="action_po_my_special_tree"/>
</record>
<record id="action_po_my_special_form2" model="ir.actions.act_window.view">
<field eval="2" name="sequence"/>
<field name="view_mode">form</field>
<field name="view_id" ref="po_my_special_form"/>
<field name="act_window_id" ref="action_po_my_special_tree"/>
</record>

specifying the "editable" attribute in two different views

i have a model that defined a nomenclator, it have only one field :
'name': fields.char('Name',size = 50,required = True),
and its view is as follow:
<record model="ir.ui.view" id="view_df_t_r_m_resource_type_tree">
<field name="name">df.t.r.m.resource.type.tree</field>
<field name="model">df.t.r.m.resource.type</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Types" editable="bottom">
<field name="name" select = "1"/>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="action_df_t_r_m_resource_type_form">
<field name="res_model">df.t.r.m.resource.type</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
</record>
I use this view to create types of product, but when i make a many2one field that reference the nomencaltor mode in other view and press the "Search" options i cant select the item because the editable property defined in the original view mess with the behavior i want
So: any ideas about how i can define the "editable" property in diferents views
PD: I tried to use this:
<field name="type_id" >
<tree>
<field name="name"/>
</tree>
</field>
but i dont know how to specify the "editable" property

Openerp 6.1 put product category in sale order line

I want to show the product category in the sale.order.line.tree view of a sales order with the following code which I wrote. It shows the category button under the group by button but on clicking it, I get the following error and I have don't know how to solve the bug:assert groupby_def and groupby_def._classic_write, "Fields in 'groupby' must be regular database-persisted fields (no function or related fields), or function fields with store=True"
AssertionError: Fields in 'groupby' must be regular database-persisted fields (no function or related fields), or function fields with store=True
Here is my code:
from osv import fields, osv<code>
class sales_order_line_category(osv.osv):
_name='sale.order.line'
_inherit='sale.order.line'
_columns={'categ_id': fields.related('product_id', 'categ_id', type='many2one', relation='product.categ_id'),
}
sales_order_line_category()
My view:
`<?xml version="1.0" encoding="utf-8"?>
<record id="view_sale_orderlinecategory" model="ir.ui.view">
<field name="name">sale.order.line.categoryinherit</field>
<field name="model">sale.order.line</field>
<field name="type">tree</field>
<field name="inherit_id" ref="sale.view_order_line_tree"/>
<field name="arch" type="xml">
<field name="name" position="after">
<field name="categ_id" string="Category"/>
</field>
</field>
</record>
<record id="view_sale_orderlinecategory2" model="ir.ui.view">
<field name="name">sale.order.line.categoryinherit2</field>
<field name="model">sale.order.line</field>
<field name="type">search</field>
<field name="inherit_id" ref="sale.view_sales_order_uninvoiced_line_filter"/>
<field name="arch" type="xml">
<group expand="0" string="Group By..." >
<filter string="Category of Product" icon="terp-stock_symbol-selection" name="Category" context="{'group_by':'categ_id'}"/>
</group>
</field>
</record>
<record id="view_sale_orderlinecategory3" model="ir.ui.view">
<field name="name">sale.order.line.categoryinherit3</field>
<field name="model">sale.order,line</field>
<field name="type">search</field>
<field name="inherit_id" ref="sale.view_sales_order_uninvoiced_line_filter"/>
<field name="arch" type="xml">
<field name="name" position="before">
<field name="categ_id" string="Category"/>
</field>
</field>
</record>
</data>
`
WOuld you please try with following code replace?
'categ_id': fields.related('product_id', 'categ_id', type='many2one', relation='product.category', store=True),
Check that your field categ_id must be appear in tree view of sale.order.line where you try to do group by categ_id
Hope this help