question about domain

Asked by julien M.

Hi,
So here are my class :

class task(osv.osv):
    _name = "project.task"
    _inherit = "project.task"
    _description = "Tasks"
    _date_name = "date_start"
    _columns = {
        'recurring':fields.boolean('Recurring'),
        }
    _defaults = {
        'recurring': lambda *a:'False',
        }
    _order = "sequence, priority, date_deadline, id"
task()

class test_contracts(osv.osv):
 _name = 'test.contracts'
 _columns = {
  'title': fields.char('Title', size=40, required=True),
  'date_contracts': fields.date('Date', required=True),
  'task_id': fields.one2many('project.task','parent_id','task'),
 }
test_contracts()

And my view :

 <record model="ir.ui.view" id="view_test_contracts_form">
   <field name="name">Contracts</field>
   <field name="model">test.contracts</field>
   <field name="type">form</field>
   <field name="arch" type="xml">
  <form string="Contracts">
   <notebook position="inside">
   <page string="General">
    <field name="title" select="1" />
    <field name="date_contracts"/>
   </page>
   <page string="Task">
    <field name="task_id" nolabel="1" mode="tree,form" colspan="4" position="replace" select="1" domain="[('recurring','=',True)]">
      <tree string="Tasks">
        <field name="name"/>
        <field name="recurring" select="1" domain="[('recurring','=',True)]"/>
      </tree>
      <form string="Task edition">
        <group colspan="6" col="6">
          <field name="name" select="1" attrs="{'readonly':[('state','=','done')]}" />
          <field name="recurring" select="1" />
        </group>
      </form>
    </field>
   </page>
   </notebook>
  </form>
   </field>
 </record>

Everything is working exept the domain, and I'm trying to find why since 3 days... Does anybody have an idea to help me please ?
Thanks =)

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Addons (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
Vinay Rana (OpenERP)
Solved:
Last query:
Last reply:
Revision history for this message
Vinay Rana (OpenERP) (vra-openerp) said :
#1

Hello Julien M. ,

You can not assign domain in one2many field.
Better you used this field as many2many Relation and in that time you can assign domain easily.

Hope this will help you.
Thanks.

Revision history for this message
julien M. (sanguinator-x) said :
#2

Thank you very much for your reply, I'm going to test it soon !

Revision history for this message
julien M. (sanguinator-x) said :
#3

Unfortunately, the domain do not work either wiht a many2many relation.... Do you have other ideas or tips ?

Revision history for this message
Best Vinay Rana (OpenERP) (vra-openerp) said :
#4

Hello Julien M. ,

There are so many example exist in tiny code where domain is used in many2many relation.
You check the following of tax in invoice line which is many2many field.
The code is exist in "addons/account/account_invoice_view.xml" path (Line number : 66 Approximately.)

Hope this will help you.

Thanks.

Revision history for this message
julien M. (sanguinator-x) said :
#5

Hello,

It works, thank you very much ! I have others problems, but this one is solved, thank you !

Revision history for this message
julien M. (sanguinator-x) said :
#6

Thanks vra (openerp), that solved my question.