Commit 21df373f by François C.

Add context to odoo api update

parent b479fafd
Pipeline #1679 passed with stage
in 1 minute 56 seconds
...@@ -47,7 +47,7 @@ class OdooAPI: ...@@ -47,7 +47,7 @@ class OdooAPI:
order='id ASC'): order='id ASC'):
"""Main api request, retrieving data according search conditions.""" """Main api request, retrieving data according search conditions."""
fields_and_context = {'fields': fields, fields_and_context = {'fields': fields,
'context': {'lang': 'fr_FR','tz':'Europe/Paris'}, 'context': {'lang': 'fr_FR', 'tz': 'Europe/Paris'},
'limit': limit, 'limit': limit,
'offset': offset, 'offset': offset,
'order': order 'order': order
...@@ -59,8 +59,11 @@ class OdooAPI: ...@@ -59,8 +59,11 @@ class OdooAPI:
def update(self, entity, ids, fields): def update(self, entity, ids, fields):
"""Update entities which have ids, with new fields values.""" """Update entities which have ids, with new fields values."""
context = {
'context': {'lang': 'fr_FR', 'tz': 'Europe/Paris'}
}
return self.models.execute_kw(self.db, self.uid, self.passwd, return self.models.execute_kw(self.db, self.uid, self.passwd,
entity, 'write', [ids, fields]) entity, 'write', [ids, fields], context)
def create(self, entity, fields): def create(self, entity, fields):
"""Create entity instance with given fields values.""" """Create entity instance with given fields values."""
......
...@@ -272,13 +272,11 @@ class CagetteProduct(models.Model): ...@@ -272,13 +272,11 @@ class CagetteProduct(models.Model):
f['name'] = re.sub(r'( \[NPA\])', '', data['name']) f['name'] = re.sub(r'( \[NPA\])', '', data['name'])
current_name = data['name'] if ('name' not in f) else f['name'] current_name = data['name'] if ('name' not in f) else f['name']
if 'fds-in-name' in data['npa']: if 'fds-in-name' in data['npa']:
f['name'] = current_name if '[FDS]' in data['name'] else current_name + " [FDS]" f['name'] = current_name if '[FDS]' in data['name'] else current_name + " [FDS]"
f['purchase_ok'] = 0 f['purchase_ok'] = 0
elif '[FDS]' in current_name: elif '[FDS]' in current_name:
f['name'] = re.sub(r'( \[FDS\])', '', current_name) f['name'] = re.sub(r'( \[FDS\])', '', current_name)
if len(data['npa']) == 0: if len(data['npa']) == 0:
f['purchase_ok'] = 1 f['purchase_ok'] = 1
res["update"] = api.update('product.template', data['id'], f) res["update"] = api.update('product.template', data['id'], f)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment