I want to restrict the account lookup (domain) based on the value entered in GL Prefix (I'll actually use some wildcards and some other logic which I'm comfortable adding later), the problem is that I'm getting a logical True or False value returned by self.x_poLineGLprefix rather than the value in the field. How do I get the actual data value of x_poLineGLprefix?
class QuickPOLine(models.Model):
_name = 'purchase.order.line'
_inherit = 'purchase.order.line'
x_poLineGLprefix = fields.Char(string='GL Prefix')
x_poLineGLaccount = fields.Many2one(
'account.account', string="Line Item Expense Account",
help="This account will be used to post the expense value of this line item.",domain=lambda self: [('code', '=', self.x_poLineGLprefix)])
Thank you for the suggestion of using the onchange call. That certainly does change the domain. Is it possible to use values from the current record in the domain function as written above. I've seen in in hr_expense.py that the domain can call a function and reference the userid fields stored in self. Is there no current record stored in self when evaluating the domain?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
1
Reply
5697
Views
hi,
just try this
@api.onchange('x_poLineGLprefix')
def onchange_x_poLineGLprefix(self):
if self.x_poLineGLprefix:
return {'domain': {
'x_poLineGLaccount': [('code', '=', self.x_poLineGLprefix)]
}}
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
Aug 20
|
2614 | ||
|
0
Apr 22
|
4737 | ||
|
1
Jan 20
|
6912 | ||
|
1
Nov 19
|
3008 | ||
|
2
Mar 15
|
5444 |