跳至内容
菜单
此问题已终结
2 回复
7471 查看

i would like to create a module which depends on sale. I created a field expiration_date according to date selected users can get a wizard through edit button to modify the date. my problem is how to write a condition on edit button i know its completely on js. so tried that way too,but don't know how to make that call thanks in advance

形象
丢弃
编写者

i don't have enough karma to comment on your post sorry..

Based on existing expiry date field on sale order, enable edit mode only if the expiry date exceeds current date .If current date exceeds, then open a wizard to enter a new expiry date.

最佳答案

Hi,


If you want to check something at the time of database write you can inherit write method :-

def write(self, cr, uid, ids, vals, context=None):
# --> your checking code here
return super(class, self).write(cr, uid, ids, vals, context=context)

write method get invoked every time we edit and save.


Or if you want to set a limitation or restriction for a field you can use _constraints or _sql_constraints:-

Using _constraints you can define Python constraints: here is syntax and example:-

_constraints
list of (constraint_function, message, fields)
def _check_company_id(self, cr, uid, ids, context=None):
for statement in self.browse(cr, uid, ids, context=context):
if statement.company_id.id != statement.period_id.company_id.id:
return False return True
_constraints = [ (_check_company_id, 'The journal and period chosen have to belong to the same company.', ['journal_id','period_id']), ]

using _sql_constraints, you can define SQL constraints to execute when generating the backing table. here is syntax and example

_sql_constraints
list of (name, sql_definition, message)
_sql_constraints = [ 
 ('number_uniq', 'unique(number, company_id, journal_id, type)',
 'Invoice Number must be unique per Company!'),
                    ]


Hope this helps.

形象
丢弃
最佳答案

Can you explain more detail what do you want to achieved (you problem) ?

i think you can do it  without JS

形象
丢弃
相关帖文 回复 查看 活动
0
10月 17
2874
2
5月 24
2335
0
12月 23
1787
1
8月 23
3543
8
12月 19
7027