Suppose I have a field in a view like below:
<field name="some_name" widget="radio"/>
where,
some_name = fields.Selection([
('val1', 'val1'),
('val2', 'val2'),
('val3', 'val3')
])
Now, suppose I have another view. There I want to get the field using xpath like:
<xpath expr="//field[#name='some_name']"></xpath>
and there I want to display only the first two options of some_name. In odoo 11, How can I do that ?
You should try this in XML file:
<field name="some_name" attrs="{'invisible':[('some_name','==','val3')]}" invisible="1"/>
Related
When I created a product in 'product.template' that time I give the image for the particular record. So the record creates successfully but when I check the attachment of that record using Postgres.
select * from ir_attachment where res_id=107 and res_model='product.template'
After I go to attachment record and check the File Content name is blank. So When I was the download the image name is given False.
So how to resolve this issue and it is odoo default flow.
In Odoo 11 this is a problem. So that you have to add an extra field for the name itself. For example;
in python class
attachment = fields.Binary(string="Attachment", track_visibility="onchange")
fname = fields.Char(string="File Name", track_visibility="onchange")
in XML:
<group>
<field name="attachment" filename="fname" widget="download_link" string="Attachment"/>
<field name="fname" invisible="1"/>
</group>
Try this, this will work. Don't forget to upvote and put tick mark too. Thanks in advance !
In Odoo 12
Python:
file_name = fields.Char("File Name")
attachment = fields.Binary("Image")
XML
<field name="file_name" invisible="1"/>
<field name="attachment" filename="file_name" widget="FieldBinary"/>
I have this object project.task that has many situations project.task.situation . In project.task.situation model I want to create a sequence so I added this record:
<record id="sequence_project_task_situation_seq" model="ir.sequence">
<field name="name">Project Task Situation Sequence</field>
<field name="code">project.task.situation</field>
<field name="prefix">Situation N°</field>
<field eval="1" name="number_next"/>
<field eval="1" name="number_increment"/>
<field eval="False" name="company_id"/>
</record>
In python code I added this:
name = fields.Char(string='Situation Number', readonly=True)
#api.model
def create(self, vals):
seq = self.env['ir.sequence'].next_by_code('project.task.situation') or '/'
vals['name'] = seq
return super(ProjectTaskSituation, self).create(vals)
what I want is each task has its own situation sequence. For example for task1 I create 2 situations so I have Situation N°1 and Situation N°2 after that I want to create situations for task2 so I'll get Situation N°3 and Situation N°4 . Which is not good cause I want for each task to start count sequence from the start. Is this possible? How is that?
I would like to perform a random sort of data coming from database using SOLR.
I found that SOLR has already a dynamicField that I can use with random field type :
<types>
...
<fieldType name="random" class="solr.RandomSortField" />
...
</types>
<fields>
...
<dynamicField name="random*" type="random" indexed="true" stored="false"/>
...
</fields>
But I don't understant how to fill the random* column. My data are issues from data import using SQL query.
Must I fill the column in db-data-config.xml and in which way ?
Thanks for any help.
Openerp, Odoo question.
I'd like to hide the row in tree view depending one field (e.g. item is not in stock).
Maybe I need to put this somewhere in tree_view.xml:
attrs="{'invisible': [('in_stock','=', 0)]}"
It would be fine, if this works, like the res_partner 'Active' flag
When 'Active' field is False, all record is disappeared.
Any advice would be appreciated!
If you want to hide the record completely than use this domain in the window action. To show only the records that matches the domain.
<field name="domain">[('in_stock', '=', 0)]</field>
You can hide using the following syntax:
<field name="flag" invisible="1"/>
<field name="x" attrs="{'invisible': [('flag','=', False)]}"/>
Here flag should be a computed field which computes the stock of current item.
so in script just make the field as:
flag = fields.Boolean("String", compute="get_stock_status")
def get_stock_status(self):
# do your computation and change values of flag accordingly
self.flag = False
What I'm trying to achieve is simple: I made a wizard that asks the user to provide a RMA ID (that's a pop-up). Once that is submitted, I perform some operations in the backend and build a list containing all the other products in the order that's being RMA'd. I then need to ask the user to verify that all those products are in the physical RMA.
Now, I'm stuck right after building my list. How can I send that list to OpenERP, have it generate a TreeView from it so that the user can individually select products that have been located (and the ones that haven't)?
I'm assuming I'll need an additional view.xml, buy I have no idea about:
1) What to insert in the <field name="arch" type="xml> node
2) How to send my custom list/object to OpenERP/odoo
In other words, I have a list that I'm trying to send to OpenERP/odoo to be displayed in a TreeView. How?
Thanks for your help!
#Pier
Considering for Odoo-v8.
From my understanding you can try the following:
In you wizard you need to have a one2many field say product_line_ids, which will shown in your wizard.
So you will two classes, see the following structure
class rma_wizard(models.Model):
_name = 'rma.wizard'
rma_id = fields.Many2one('rma.master',string="RMA")
prodcut_line_ids = fields.One2many('product.line','wizard_id',string="Products")
#api.onchange('rma_id')
def rma_id_change(self):
code to get the list of products and use the following code to add in the wizard
final_products_list = []
products= {}
for product in product_list:
result = {}
result.update({'product_id':product.id})
final_product_list.append(result)
self.product_line_ids= final_product_list
class product_line(models.Model):
_name='product.line'
wizard_id = fields.Many2one('rma.wizard',stirng="RMA")
product_id=fields.Many2one('product.product',string="Products")
select_product=fields.Boolean("Select")`
and the Views:
<record name="rma_wizard_view" model="ir.ui.view"/>
<field name="name">RMA Wizard</fieeld>
<field name="model">rma.wizard</field>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="rma_id"/>
<field name="product_line_ids>
<tree string="Products">
<field name="product_id"/>
<field name="select_product"/>
</tree>
</field>
</field>
</record>
Now you can put the check mark select as per your need and perform operation on it
Hope this helps!!