How define gray footer under one2many_list for sum, eg.
https://postimg.org/image/jc9alzoeh/
Just in the embedded tree of your One2many field add sum="Title":
<field name="o2m_field_name" >
<tree>
...
<field name="field_name" sum="Total field name"/>
</tree>
<form>
....
...
</form>
</field
You just need to add sum attribute to the duration field.
An example with invoice lines:
<field name="invoice_line" nolabel="1" widget="one2many_list" context="{'type': type}">
<tree string="Invoice Lines" editable="bottom">
<field name="sequence" widget="handle"/>
<field name="product_id" on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, parent.company_id, context)"/>
<field name="name"/>
<field name="company_id" invisible="1"/>
<field name="account_id" groups="account.group_account_user" domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '=', 'other')]" on_change="onchange_account_id(product_id, parent.partner_id, parent.type, parent.fiscal_position,account_id)"/>
<field name="account_analytic_id" groups="analytic.group_analytic_accounting" domain="[('type','!=','view'), ('company_id', '=', parent.company_id), ('state','not in',('close','cancelled'))]"/>
<field name="quantity"/>
<field name="uos_id" groups="product.group_uom" on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, parent.company_id, context)"/>
<field name="price_unit"/>
<field name="discount" groups="sale.group_discount_per_so_line"/>
<field name="invoice_line_tax_id" widget="many2many_tags" context="{'type':parent.type}" domain="[('parent_id','=',False),('company_id', '=', parent.company_id)]"/>
<field name="price_subtotal" sum='Total'/>
</tree>
It should looks like:
<field name="field name" nolabel="1" widget="one2many_list">
<tree editable="bottom">
...
<field name="duration" sum='Total'/>
</tree>
</field>
Related
In the product category, I added a product_ids field and I want to display it with a tree view showing name and default_code of products. For some reason I get the error "Field default_code does not exist"
<record id="view_product_category_qty_discount" model="ir.ui.view">
<field name="name">product.category.inherit.qty.discount.Config Hetlita</field>
<field name="model">product.category</field>
<field name="type">form</field>
<field name="inherit_id" ref="product.product_category_form_view" />
<field name="arch" type="xml">
<form position="inside">
<group col="2" colspan="2">
<separator string="Quantity for discount" colspan="2"/>
<field name="qty_for_discount" />
</group>
<group>
<field name="product_ids" widget="many2many_tags"/>
<tree>
<field name="name"/>
<field name="default_code"/>
</tree>
</group>
</form>
</field>
</record>
class ProductCategory(models.Model):
_inherit = 'product.category'
qty_for_discount = fields.Float(string='Qty For Discount')
product_ids = fields.Many2many(
'product.template', string='Products')
That's because there is no default_code on model product.template but instead on its variants with model product.product. I would change the field on product.category to a One2Many on product.product:
product_ids = fields.One2many(
comodel_name='product.product',
inverse_name='categ_id',
string='Products')
And there is a mistake in your xml:
<group>
<field name="product_ids">
<tree>
<field name="name"/>
<field name="default_code"/>
</tree>
</field>
</group>
In order to be able to select a batch/lot more easily according to minimum life time requirements, I would like to have the value of the variable use_date (of module product.expiry) displayed next to the batch number in the view 'stock.view_pack_operation_lot_form'.
The view (belonging to the model stock.pack.operation) is defined as follows (default):
<record id="view_pack_operation_lot_form" model="ir.ui.view">
<!-- ... -->
<field name="pack_lot_ids" nolabel="1" attrs="{'readonly': [('state', '=', 'done')]}">
<tree editable="bottom" decoration-success="qty_todo==qty"
decoration-danger="(qty_todo > 0) and (qty>qty_todo)">
<field name="lot_name" invisible="not context.get('only_create', False)"/>
<field name="lot_id" invisible="context.get('only_create', False)"
domain="[('product_id','=', parent.product_id)]"
context="{'default_product_id': parent.product_id, 'active_pack_operation': parent.id}"/>
<field name="qty_todo"
invisible="not context.get('show_reserved') or context.get('serial') or context.get('state_done')"
readonly="1"/>
<field name="qty" invisible="context.get('serial')"/>
<button name="do_minus" type="object" icon="fa-minus-square" attrs="{'invisible': [('qty', '<=', 0.99)]}"
invisible="not context.get('show_reserved') or context.get('state_done')"/>
<button name="do_plus" type="object" icon="fa-plus-square" attrs="{'invisible': [('plus_visible', '=', False)]}"
invisible="not context.get('show_reserved') or context.get('state_done')"/>
<field name="plus_visible" invisible="1"/>
</tree>
</field>
<!-- ... -->
</record>
The field pack_lot_ids is defined as One2many with reference to 'stock.pack.operation.lot' in the model 'stock.pack.operation'.
'stock.pack.operation.lot' has a field lot_id which is defined as Many2one with a reference to 'stock.production.lot'. 'stock.production.lot' contains the field use_date which I want to add to the view.
My first attempt was to add the field in dot notation as follows "reference.field_name":
<record id="stock_pack_operation_lots_form_inherit" model="ir.ui.view">
<field name="name">stock.pack.operation.lots.form.inherit</field>
<field name="model">stock.pack.operation</field>
<field name="inherit_id" ref="stock.view_pack_operation_lot_form"/>
<field name="arch" type="xml">
<field name="lot_id" position="after">
<field name="lot_id.use_date"/>
</field>
</field>
</record>
Which caused the following error:
Error context:
View `stock.pack.operation.lots.form`
[View_id: 722, xml_id: stock.view_pack_operation_lot_form, model: stock.pack.operation, parent_id: n / a]
I then found this and this post on SO suggesting a definition as subview:
<!-- ... -->
<field name="arch" type="xml">
<field name="lot_id" position="after">
<field name="lot_id" nolabel="1">
<tree>
<field name="use_date"/>
</tree>
</field>
</field>
</field>
<!-- ... -->
This time it didn't throw an error, but instead of the field use_date it added the field lot_id a second time.
Any hint of how to add the use_date field next to the batch number is appreciated!
you could create a related field in the model stock.pack.operation.lot:
use_date = fields.Char(string='Use date', related='lot_id.use_date')
and then you could add it to your view:
<!-- ... -->
<field name="pack_lot_ids" nolabel="1" attrs="{'readonly': [('state', '=', 'done')]}">
<tree editable="bottom" decoration-success="qty_todo==qty"
decoration-danger="(qty_todo > 0) and (qty>qty_todo)">
<field name="lot_name" invisible="not context.get('only_create', False)"/>
<field name="lot_id" invisible="context.get('only_create', False)"
domain="[('product_id','=', parent.product_id)]"
context="{'default_product_id': parent.product_id, 'active_pack_operation': parent.id}"/>
<field name="use_date" />
<field name="qty_todo"
invisible="not context.get('show_reserved') or context.get('serial') or context.get('state_done')"
readonly="1"/>
<field name="qty" invisible="context.get('serial')"/>
<button name="do_minus" type="object" icon="fa-minus-square" attrs="{'invisible': [('qty', '<=', 0.99)]}"
invisible="not context.get('show_reserved') or context.get('state_done')"/>
<button name="do_plus" type="object" icon="fa-plus-square" attrs="{'invisible': [('plus_visible', '=', False)]}"
invisible="not context.get('show_reserved') or context.get('state_done')"/>
<field name="plus_visible" invisible="1"/>
</tree>
</field>
<!-- ... -->
I hope this help you
I want to do Group by by City but this possibility doesn't shows up. where is my mistake? there is field city in python file and it's showing up in tree view but not really in Group by
<openerp>
<data>
<record id="vpicktree" model="ir.ui.view">
<field name="name">Picking tree city</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.vpicktree"/>
<field name="arch" type="xml">
<field name="location_dest_id" position="after">
<field name="city"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="stock_picking_filter_city_search">
<field name="name">stock.picking.tree.filter_search</field>
<field name="model">stock.picking</field>
<field name="arch" type="xml">
<search string="City">
<filter name="city" string="City" context="{'group_by':'city'}"/>
</search>
</field>
</record>
<record id="action_picking_tree_city" model="ir.actions.act_window">
<field name="name">City</field>
<field name="res_model">stock.picking</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">tree,kanban,calendar</field>
<field name="domain"></field>
<field name="context">{ 'group_by':'city' }</field>
<field name="search_view_id" ref="stock.view_picking_internal_search"/>
</record>
</data>
</openerp>
The group by must be in search view not on the action setion as you did, so you have to edit your search view:
<record model="ir.ui.view" id="stock_picking_filter_city_search">
<field name="name">stock.picking.tree.filter_search</field>
<field name="model">stock.picking</field>
<field name="arch" type="xml">
<search string="City">
<filter name="city" string="City" context="{'group_by':'city'}"/>
<group expand="0" string="Grouper par">
<filter string="City" icon="terp-personal" domain="[]" context="{'group_by':'city'}"/>
</group>
</search>
</field>
</record>
Hi I have a mode Unit which inherits product.product.
I have defined the custom views for Unit and they work fine from the menu.
Property which inherits account.asset.assets has multiple units.
How do I call my custom unit views from the Property view?
When I click on Add an item I get the standard product form.
<record id="unit_form" model="ir.ui.view">
<field name="name">All Units</field>
<field name="model">product.product</field>
<field name="sequence">0</field>
<field name="arch" type="xml">
<form string="Unit">
<group>
<field name="property_id" widget="many2one" attrs="{'required': [('is_unit', '=', True)]}" />
<field name="is_unit" invisible="1" />
<field name="features_amenities_ids" placeholder="Features and Amenities" widget="many2many_tags" />
<field name="appliences_ids" placeholder="Apliences" widget="many2many_tags" />
<field name="lst_price" string="Rent" />
</group>
</form>
</field>
</record>
<record id="unit_tree" model="ir.ui.view">
<field name="name">All Units</field>
<field name="model">product.product</field>
<field name="arch" type="xml">
<tree string="Units" default_order='property_id,name'>
<field name="property_id" />
<field name="name" string="Unit#" />
</tree>
</field>
</record>
<record id="action_unit" model="ir.actions.act_window">
<field name="name">Units</field>
<field name="res_model">product.product</field>
<field name="view_mode">search, kanban,tree,form</field>
<field name="domain">[('is_unit', '=', True)]</field>
<field name="context">{'default_is_unit':1 }</field>
<field name="search_view_id" ref="unit_search"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a Unit.
</p>
<p>
Here you will find the all units.
</p>
</field>
</record>
<record id="action_unit_form" model="ir.actions.act_window.view">
<field name="act_window_id" ref="action_unit" />
<field name="view_id" ref="unit_form" />
<field name="view_mode">form</field>
<field name="sequence">10</field>
</record>
<record id="action_unit_tree" model="ir.actions.act_window.view">
<field name="act_window_id" ref="action_unit" />
<field name="view_id" ref="unit_tree" />
<field name="view_mode">tree</field>
<field name="sequence">9</field>
</record>
<record id="action_unit_kanban" model="ir.actions.act_window.view">
<field name="act_window_id" ref="action_unit" />
<field name="view_id" ref="product.product_kanban_view" />
<field name="view_mode">kanban</field>
<field name="sequence">8</field>
</record>
<menuitem action="action_unit" sequence="2"
id="menu_units_list" name="Units" parent="menu_property_sub"/>
This is from Property
<notebook colspan="4">
<page string="Units">
<field name="unit_ids" nolabel="1" widget="one2many" >
<tree string="Units">
<field name="name" string="Unit#"/>
</tree>
</field>
</page>
</notebook>
If you want to specify a view for many2one or one2many field:
<field name="m2o_id" context="{'form_view_ref': 'module_name.form_id'}"/>
hope this helps. there are other key word like tree_view_ref for tree views
I'm grouping POLine by Order Reference by Manual , it filtering the data as shown in below image.
<record id="view_purchase_line_search" model="ir.ui.view">
<field name="name">purchase.order.line.search</field>
<field name="model">purchase.order.line</field>
<field name="arch" type="xml">
<search string="Search Purchase Order">
<field name="order_id"/>
<field name="partner_id" string="Supplier" filter_domain="[('partner_id', 'child_of', self)]"/>
<group expand="1" string="Group By...">
<filter icon="terp-gtk-jump-to-rtl" string="Order Reference" domain="[]" context="{'group_by' :'order_id'}"/>
<filter string="Supplier" icon="terp-partner" domain="[]" context="{'group_by' : 'partner_id'}" />
</group>
</search>
</field>
</record>
<record id="view_purchase_line_list" model="ir.ui.view">
<field name="name">purchase.order.line.tree</field>
<field name="model">purchase.order.line</field>
<field name="arch" type="xml">
<tree string="Purchase Order Lines" create="false">
<field name="order_id"/>
<field name="partner_id" string="Supplier" />
<field name="product_id"/>
<field name="price_unit"/>
<field name="product_qty"/>
<field name="product_uom" groups="product.group_uom"/>
<field name="price_subtotal"/>
<field name="date_planned" widget="date" width="135"/>
<field name="state" invisible="1"/>
<field name="invoiced" invisible="1"/>
</tree>
</field>
</record>
<record id="action_purchase_line_list" model="ir.actions.act_window">
<field name="name">PO Tree Structure</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">purchase.order.line</field>
<field name="view_id" ref="view_purchase_line_list"/>
<field name="context">{'search_default_order_id':1 }</field>
<field name="search_view_id" ref="view_purchase_line_search"/>
</record>
<menuitem action="action_purchase_line_list" id="menu_purchase_list"
parent="menu_procurement_management"
sequence="0"/>
But i need this filter by default (i.e) when openning this window at first time it should groupped the data
Tried Below Code:
<field name="context">{'search_default_order_id':1 }</field>
I need "Order Reference" instead of Order Reference POOOO1 in search field.
Any Advice will be helpful.
update your code with this.
<filter name="groupby_order" icon="terp-gtk-jump-to-rtl" string="Order Reference"
domain="[]" context="{'group_by' :'order_id'}"/>
and pass <field name="context">{'search_default_groupby_order': 1}</field> in
act_window. Hope this will be useful to you.
try this, In your purchase_view.xml file search this id view_purchase_order_filter and than add below filter in Group By...
<filter icon="terp-gtk-jump-to-rtl" name="order_id" string="Order Reference" domain="[]" context="{'group_by' :'name'}"/>
Than find this id purchase_form_action and paste below context
<field name="context">{'search_default_order_id': 1}</field>
Hope this will help you.