Skip to content

Commit

Permalink
Merge pull request #20 from granzonchen/sync_odoo_data
Browse files Browse the repository at this point in the history
Sync odoo data
  • Loading branch information
feitas authored Oct 31, 2022
2 parents 7e5b566 + d6c9c73 commit 51b1452
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
32 changes: 17 additions & 15 deletions syd_process_maker/models/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,25 @@ def _compute_is_assigned_to(self):
for record in self:
record.is_assigned_to = bool(record.pm_assigned_to.id == self.env.uid)

@api.model
def create(self, vals):
case = super(Case, self).create(vals)
_vals = {
"res_name": "",
"date_deadline": case.date_deadline,
"activity_type_id": self.env['ir.model.data']._xmlid_to_res_id('mail.mail_activity_data_todo', raise_if_not_found=False),
"user_id": case.pm_assigned_to.id,
"summary": "",
"res_id": int(case.related_id),
"res_model_id": self.env['ir.model'].search([('model', '=', case.related_model)]).id
}
if case.activity_id and "-" in case.activity_id.name:
_vals.update({"res_name": case.activity_id.name.split('-')[1]})

activity = self.env['mail.activity'].create(_vals)
print(activity)
case.write({'odoo_activity_id': activity.id})
if case.related_model:
_vals = {
"res_name": "",
"date_deadline": case.date_deadline,
"activity_type_id": self.env['ir.model.data']._xmlid_to_res_id('mail.mail_activity_data_todo', raise_if_not_found=False),
"user_id": case.pm_assigned_to.id,
"summary": "",
"res_id": int(case.related_id),
"res_model_id": self.env['ir.model'].search([('model', '=', case.related_model)]).id
}
if case.activity_id and "-" in case.activity_id.name:
_vals.update({"res_name": case.activity_id.name.split('-')[1]})

activity = self.env['mail.activity'].create(_vals)
print(activity)
case.write({'odoo_activity_id': activity.id})
return case


Expand Down
7 changes: 2 additions & 5 deletions syd_process_maker/models/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def start_process(self, process_id,related_model=False,related_id=False):
par = {'process_id': int(pm_process_id), 'event': 'node_1'}
res = self._call(f'process_events/{pm_process_id}', query_param=par, method='POST')
process_id.name = res['name']
# FIXME? 为什么要存储
# Synchronous the process data when create a request
process_id.pm_process_id = res.get('process_id')
_process_dict = res.get('process')
if _process_dict:
Expand Down Expand Up @@ -512,13 +512,10 @@ def _parse_json(self):

def _create_dynamic_form_from_parsed_files(self):
"""
TODO 解析下载的process json文件,写到Dynamic Form
Write the json data to the 'Dynamic Form'
"""
# 2.创建Dynamic Form记录来存放Screen,Name->Screen Name,添加一个字段Element Name
# Name->Screen Name,ID->Screen ID
if self.export_data and isinstance(self.export_data, str):
_data_dict = json.loads(self.export_data)
_logger.warning(_data_dict)
_screen_list = _data_dict.get('screens')
for _screen in _screen_list:
_screen_record = self.env['syd_bpm.dynamic_form'].search([('pm_screen_id','=',_screen.get('id')),('name','=',_screen.get('config')[0].get('name'))])
Expand Down

0 comments on commit 51b1452

Please sign in to comment.