i'm use odoo12, and i try to add check concurrency in a form view(eg: user A and B open form view same times,then A change value, so when b change values,odoo will warn user B that record has been change).
i notice that odoo already has a method `_check_concurrency` and will be call in every `write` method, it just need add `__last_update`field in env.
so i just simply add such code in file`odoo/addons/web/static/src/js/views/basic/basic_model.js`
and method `_getContext`
```
_getContext: function (element, options) {
........
.......
if (element.viewType === "form" && element.data.__last_update) {
var nex = {'__last_update': {}};
var rid = element.model.concat(',', element.data.id);
nex['__last_update'][rid] = element.data.__last_update.utc().format();
context.add(nex);
}
return context.eval();
}
```
with this change, when i change form value, odoo will call `_check_concurrency` method, but i notice that in odoo client `__last_update` is without millisecond like `2020-03-09 05:40:09`, but in odoo database, field is full timestamp like `2020-03-09 05:40:09.04263`, so in `_check_concurrency` method, when compare time by the code
```
check_clause = "(id = %s AND %s < COALESCE(write_date, create_date, (now() at time zone 'UTC'))::timestamp)"
```
will found record so that reocrd can't change
my questions is two:
1. is it my change to code is correct way to solve check concurrency in a form view?
2. if is true, what should i do? At first i want to change some code to convert `__last_update` return format. but i have no idea