I want to hide equipments that are not in an inventory. I've tried with
<record id="view_inventory_equipment_tree" model="ir.ui.view">
<field name="name">maintenance.equipment.tree</field>
<field name="model">maintenance.equipment</field>
<field name="domain">[('inventory_id','=',False)]</field>
<field name="arch" type="xml">
<tree string="Lot/Serial Number Inventory">
<field name="name"/>
<field name="serial_no"/>
<field name="category_id"/>
<field name="inventory_id"/>
<field name="cost"/>
</tree>
</field>
</record>
But that did not work, also there is no luck with
<field name="domain_force">[('inventory_id','=',False)]</field>
My model:
class MaintenanceEquipment(models.Model):
_name = 'maintenance.equipment'
_description = 'Equipment'
name = fields.Char('Equipment Name', required=True, translate=True)
inventory_id = fields.Many2one('maintenance.equipment.inventory', string='Equipment Inventory', track_visibility='onchange')
Put domain in action window record. Domain not work in directly with any view like tree or form view.
Related
I want to add user_id to model ir.values to give user with id=1 possiblity to view an action
I dont know how that works
<record id="value_force_availability" model="ir.values">
<field name="model_id" ref="stock.model_stock_picking" />
<field name="name">Force Availability</field>
<field name="user_id">user</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' +
str(ref('action_force_availability'))"/>
<field name="key">action</field>
<field name="model">stock.picking</field>
</record>
Use field ref attribute with a user external id.
Example using Administrator user:
<field name='user_id' ref='base.user_root'/>
I'm trying to add multi field to timesheet module to work as a tasks manage app i did inheritance to account.analytic.line the problem is in the view i got that error "AssertionError: Element odoo has extra content: record, line 4"
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="todo_timesheet_line_tree" model="ir.ui.view">
<field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_tree"/>
<field name="model">account.analytic.line</field>
<field name="arch" type="xml"/>
<field name="task_id" position="after">
<field name="priority"/>
</field>
<field name="company_id" groups="base.group_multi_company" position="before">
<field name="gov_department"/>
<field name="priority"/>
<field name="date_deadline"/>
</field>
</record>
</odoo>
from odoo import models, fields, api
class TodoTask(models.Model):
_inherit = 'account.analytic.line'
startdate=fields.Date('start Date', required=True, index=True, default=fields.Date.context_today)
date_deadline=fields.Date('Deadline', required=True, index=True, default=fields.Date.context_today)
priority = fields.Selection(selection=[('1', 'فوري'), ('2','هام جدا' ),('3','اقل اهمية')])
is_done = fields.Boolean ('Done?')
gov_department = fields.Many2one('govauthority','الجهة الحكومية')
class govauthority(models.Model):
govname = fields.Char('GOV_Department', size=25, required=True)
The error is in this line
<field name="arch" type="xml" />
You closed the tag while you really should not. Within this tag the actual XML body should be.
<record id="todo_timesheet_line_tree" model="ir.ui.view">
<field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_tree" />
<field name="model">account.analytic.line</field>
<field name="arch" type="xml">
<field name="task_id" position="after">
<field name="priority" />
</field>
<field name="company_id" groups="base.group_multi_company" position="before">
<field name="gov_department" />
<field name="priority" />
<field name="date_deadline" />
</field>
</field>
</record>
I am using Odoo 10-e. I am working on a sample module.
I have 5 models (customer, product, order, order details, movement)
Customer :
class Customer(models.Model):
_name ="amgl.customer"
…… all other fields related to customer
product_ids = fields.Many2many('amgl.products', string='Products')
Products :
class Products(models.Model):
_name ="amgl.products"
…… all other fields related to product
customer_ids = fields.Many2many('amgl.customer', string='Customers')
Order :
class Order(models.Model):
_name ="amgl.order"
order_line = fields.One2many('amgl.order_line', 'order_id', string='Order Lines')
…… all other fields related to Order
Order Details :
class OrderLine(models.Model):
_name = 'amgl.order_line'
order_id = fields.Many2one('amgl.order', string='Orders')
products = fields.Many2one('amgl.products', string="Products")
…… all other fields related to order details
Movement
class Movement(models.Model):
_name = 'amgl.metal_movement'
customer = fields.Many2one("amgl.customer", string="Customer", required=True)
order_lines = fields.One2many('amgl.order_line','metal_movement_id')
…… all other fields related to movement
What i am trying to do is, i am creating a movement form in which user will select a customer from customer drop down first then user will add order_lines and in that he will be able to add products i want to filter products which are associated with above selected customer . How can i do that ? I have been trying since last month.
Movement View
<odoo>
<data>
<record id="action_metal_movement" model="ir.actions.act_window">
<field name="name">Metal Movement Request</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">metal.movement</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create
</p><p>
<!-- More details about what a user can do with this object will be OK -->
</p>
</field>
</record>
<record id="form_metal_movement" model="ir.ui.view">
<field name="name">Metal Movement Request </field>
<field name="model">metal.movement</field>
<field name="arch" type="xml">
<form string="Metal Movement">
<sheet>
<group>
<group string="Metal Movement Request">
<field name="date_create" string="Date Created"/>
<field name="reference"/>
<field name="metal_movement_type"/>
<field name="first_approve"/>
<field name="second_approve" domain="[('id', '!=', first_approve)]"/>
<field name="customer"/>
<field name="sepcial_instruction" widget="html"/>
</group>
<group string="Metal Movement From">
<group colspan="6">
<field name="custodian"/>
<field name="mmf_name"/>
<field name="mmf_account_number"/>
<field name="mmf_account_type"/>
</group>
<group string="Metal Movement To" colspan="6">
<field name="mmt_name"/>
<field name="mmt_address" attrs="{'invisible':[('metal_movement_type', '=', 'IT')]}"/>
<field name="mmt_account_number" />
<field name="mmt_company" attrs="{'invisible':[('metal_movement_type','not in',('AC','IPPU','IT'))]}"/>
<field name="pickup_date" string="Pick up Datetime" attrs="{'invisible':[('metal_movement_type','not in',('AC','IPPU'))]}"/>
</group>
</group>
<group string="Metals To Be Moved" colspan="12">
<field name="order_lines">
<tree editable="bottom">
<field name="quantity" string="Quantity"/>
<field name="products" domain="[('customer_ids','in', parent.customer)]" string="Product Name"/>
<field name="weight" string="Weight"/>
<field name="total_weight" string="Total Weight"/>
</tree>
</field>
</group>
</group>
</sheet>
</form>
</field>
</record>
</data>
</odoo>
Thank you for updation of question.
First add customer in product field context.
<field name="order_lines">
<tree editable="bottom">
<field name="quantity" string="Quantity"/>
<field name="products" context="{'customer_id':parent.customer}" string="Product Name"/>
<field name="weight" string="Weight"/>
<field name="total_weight" string="Total Weight"/>
</tree>
</field>
Then in product's model write it's name_get method like this.
#api.multi
def name_get(self):
if self.env.context('customer_id',False):
customer = self.env['amgl.customer'].browse(self.env.context('customer_id',False))
for product in customer.product_ids:
res.append((product.id,product.name))
else:
res=super(product_product,self).name_get()
return res
Thats it.
Get an error: Odoo Warning - Insufficient fields for Calendar View! and the calendar, of course,never shows up.
I'm missing something but don't know what;
I have this view fragment:
<record model="ir.actions.act_window" id="action_soft_apps_event">
<field name="name">Applications</field>
<field name="res_model">soft.app</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="arch" type="xml">
<calendar string="App Releases" color="dev_id" date_start="release" date_delay="1">
<field name="name"/>
<field name="desc"/>
<field name="downloads"/>
<field name="valid"/>
</calendar>
</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">Register a new App</p>
</field>
</record>
And the model is the following:
class soft_app(osv.osv):
"""Apps"""
_name = 'soft.app'
_columns = {
'name': fields.char('Name', size=32, required=True, help='This is the name of the application'),
'desc': fields.text('Description', help='A brief description of the application'),
'dev_id': fields.many2one('soft.dev','Developer',required=True, help='The app\'s developer'),
'release': fields.datetime('Release Date', help='The date that the app was released'),
'downloads': fields.integer('Download Count', help='Total amount of downloads'),
'user_ids': fields.many2many('soft.user','soft_user_app_rel','app_id','user_id','Users Downloaded', help='Users that have downloaded the app'),
'os_ids': fields.many2many('soft.os','soft_os_app_rel','app_id','os_id','Operating Systems', help='Operating systems survey data'),
'valid': fields.boolean('Is Valid', help='Checks if the app is validated')
}
soft_app()
I think you have to create separate calendar view and action
Like:
Calendar view
<record id="view_invoice_line_calendar" model="ir.ui.view">
<field name="name">account.invoice.calendar</field>
<field name="model">account.invoice</field>
<field name="arch" type="xml">
<calendar string="Invoices" color="journal_id" date_start="date_invoice">
<field name="partner_id"/>
<field name="amount_total"/>
</calendar>
</field>
</record>
Action
<record id="action_invoice_tree" model="ir.actions.act_window">
<field name="name">Invoices</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="view_id" ref="invoice_tree"/>
<field name="context">{'type':'out_invoice'}</field>
<field name="search_view_id" ref="view_account_invoice_filter"/>
</record>
I have inherited 'sales order' from 'sales' module.
I need to add two extra fields inside 'Order Lines' tab.
.py
class SalesOrderInherit(models.Model):
_inherit = "sale.order"
type = fields.Selection([('appointment', 'Appointment'), ('walkin', 'Walk-In')], string="Type")
I need to add type field inside 'Order Lines' tab.
Which table should i inherit?
How to write to add above field.
Got Solution
<record id="inherit_sale_order_line" model="ir.ui.view">
<field name="name">inherit.sale.order.line.form.view</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="priority" eval="50" />
<field name="arch" type="xml">
<xpath expr="//field[#name='order_line']/tree/field[2]" position="after">
<field name="type"/>
</xpath>
</field>
</record>