I have a domain to filter table2 from table1's value: Is there a way that I can get the values of table1 to filter table2's many2one, during creation of record?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- إدارة علاقات العملاء
- e-Commerce
- المحاسبة
- المخزون
- PoS
- Project
- MRP
لقد تم الإبلاغ عن هذا السؤال
All right, below is my solution but im pretty sure there is a better way to do this:
#Declare as public def get_allotment_id(allot_id): a = {'allotment_id':allot_id} return a
allotment = []
#Under BOM class #I defined on_change function class bom(osv.osv): .... ....
def onchange_allotment(self, cr, uid, ids, allot_id, context=None):
if allot_id:
x = get_allotment_id(allot_id)['allotment_id']
if len(allotment) > 0:
allotment.pop()
allotment.append(x)
return {'value': {'contingency':0.00}} #just return any value in some field
# class bom_lines(osv.osv): .... ....
def _get_allot_id(self, cr, uid, context):
if allotment:
return allotment[0]
else:
raise osv.except_osv('', 'Please select allotment for this BOM.')
_columns = {
'allotment_id': fields.many2one('res.allotments', 'Allotment'),
'category_id': fields.many2one('res.allotment.category', 'Category', domain="[('allot_id','=',allotment_id)]", required=True),
}
.....
_defaults = { 'allotment_id': _get_allot_id,
Hello,
Does records are in relation table1's and table2's?
If yes then you able to us browse method and access all relations fields.
or do self.pool.get('tablex').browse(...., ids,...) and implement logic.
Note: In term of openerp table refer as model. so instead of table use model word when you working with openerp model/class.
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!
أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!
تسجيلالمنشورات ذات الصلة | الردود | أدوات العرض | النشاط | |
---|---|---|---|---|
|
3
سبتمبر 20
|
71899 | ||
|
1
سبتمبر 19
|
3140 | ||
|
2
سبتمبر 23
|
9602 | ||
|
1
أبريل 22
|
2523 | ||
Many2One Domain
تم الحل
|
|
1
يوليو 20
|
5690 |
Hi Charlie,
Please bare with my english =)
Thank you for that information, yes they are related and I used to browse record from models using that method. I attached a screenshot for your reference.
Just solve it myself =)
You may explain how you resolved your issue as an answer and accept your own answer. :)