Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
548 Vistas

We are currently facing an issue with Odoo’s built-in workflow for sending offer letters and contracts via the Sign module.

The issue is that both the employer and the employee receive the document link at the same time. However, if the employee opens the email before the employer has validated or completed their section, the document appears blank or incomplete — as the required data has not yet been filled in by the employer.

This leads to confusion and disrupts our onboarding process. Ideally, the employer should validate or complete the offer letter first, and only then should the employee be notified or allowed to sign.

Important Note:

We are not using the manual Send Sign Request wizard. The sign request is being triggered through automation rules, so we don’t have manual control over the sequence or timing of sign request emails.

Has anyone encountered this issue or found a reliable solution? Is there a way to control signer sequence or delay the employee's email until the employer has signed?

Any suggestions or workarounds would be greatly appreciated.

Avatar
Descartar
Autor

_logger.info("Rule 1: Offer Letter script triggered for Applicant ID %s", record.id)

template = env['sign.template'].search([('name', '=', 'UAE Employee Employment Contract.pdf')], limit=1)
if not template:
raise UserError("Offer Letter template not found.")

roles = template.sign_item_ids.mapped('responsible_id')

employee_email = record.email_from
employer_email = record.user_id.partner_id.email if record.user_id and record.user_id.partner_id else None

if not (template and roles and employee_email and employer_email):
raise UserError("Missing template, roles, or required emails. Offer letter generation failed.")

# Prefill Data
current_date = record.create_date.strftime('%d/%m/%Y') if record.create_date else ''
formatted_start_date = ''
if record.x_studio_start_date:
try:
formatted_start_date = record.x_studio_start_date.strftime('%d/%m/%Y')
except Exception:
formatted_start_date = str(record.x_studio_start_date)

value_dict = {
'Date': current_date,
'Job Title': record.x_studio_job_title or '',
'Start Date': formatted_start_date,
'Work Location': record.x_studio_country_of_employment or '',
'Salary': record.x_studio_monthly_daily_hourly_rate or '',
'Medical': record.x_studio_medical_insurance_provided or '',
'Employment Type': record.x_studio_employment_type or '',
'Name': record.x_studio_preferred_name or '',
}

prefill_values = []
for item in template.sign_item_ids:
if item.name in value_dict:
prefill_values.append((0, 0, {
'sign_item_id': item.id,
'value': value_dict[item.name],
}))

_logger.info("Rule 1: Prepared sign request items for Applicant ID %s", record.id)

request_items = []
for role in roles:
if role.name == 'Employer':
request_items.append((0, 0, {
'role_id': role.id,
'partner_id': record.user_id.partner_id.id if record.user_id and record.user_id.partner_id else False,
'signer_email': employer_email,
'sign_item_value_ids': prefill_values, # Employer can review and edit these fields
}))
elif role.name == 'Employee':
request_items.append((0, 0, {
'role_id': role.id,
'partner_id': record.partner_id.id if record.partner_id else False,
'signer_email': employee_email,
}))

if not request_items:
raise UserError("No signing roles found in the offer letter template.")

# Create Sign Request with Sequential Signing (Employer first)
env['sign.request'].create({
'template_id': template.id,
'reference': f"Offer-{record.id}",
'subject': f"Employment Contract - {record.partner_name or record.name}",
'request_item_ids': request_items,
})

_logger.info("Rule 1: Offer Letter sent successfully for Applicant ID %s", record.id)

Autor

After the provided modified script I am getting this error -

RPC_ERROR

Odoo Server Error

Occured on crm.codification.io on model hr.applicant and id 38 on 2025-06-03 09:26:34 GMT

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/tools/safe_eval.py", line 397, in safe_eval
return unsafe_eval(c, globals_dict, locals_dict)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ir.actions.server(1066,)", line 67, in <module>
File "<decorator-gen-517>", line 2, in create
File "/usr/lib/python3/dist-packages/odoo/api.py", line 495, in _model_create_multi
return create(self, [arg])
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/addons/base_automation/models/base_automation.py", line 774, in create
records = create.origin(self.with_env(automations.env), vals_list, **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<decorator-gen-166>", line 2, in create
File "/usr/lib/python3/dist-packages/odoo/api.py", line 496, in _model_create_multi
return create(self, arg)
^^^^^^^^^^^^^^^^^
File "/mnt/enterprise-addons/documents_sign/models/sign_request.py", line 13, in create
sign_requets = super().create(vals_list)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "<decorator-gen-107>", line 2, in create
File "/usr/lib/python3/dist-packages/odoo/api.py", line 496, in _model_create_multi
return create(self, arg)
^^^^^^^^^^^^^^^^^
File "/mnt/enterprise-addons/sign/models/sign_request.py", line 177, in create
sign_requests = super().create(vals_list)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "<decorator-gen-50>", line 2, in create
File "/usr/lib/python3/dist-packages/odoo/api.py", line 496, in _model_create_multi
return create(self, arg)
^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/addons/mail/models/mail_thread.py", line 268, in create
threads = super(MailThread, self).create(vals_list)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<decorator-gen-0>", line 2, in create
File "/usr/lib/python3/dist-packages/odoo/api.py", line 496, in _model_create_multi
return create(self, arg)
^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/models.py", line 4954, in create
raise ValueError("Invalid field %r on model %r" % (key, self._name))
ValueError: Invalid field 'signing_order' on model 'sign.request'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/http.py", line 1962, in _transactioning
return service_model.retrying(func, env=self.env)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 156, in retrying
result = func()
^^^^^^
File "/usr/lib/python3/dist-packages/odoo/http.py", line 1929, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/http.py", line 2177, in dispatch
result = self.request.registry['ir.http']._dispatch(endpoint)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py", line 333, in _dispatch
result = endpoint(**request.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/http.py", line 727, in route_wrapper
result = endpoint(self, *args, **params_ok)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/dataset.py", line 36, in call_kw
return call_kw(request.env[model], method, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/api.py", line 533, in call_kw
result = getattr(recs, name)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/addons/web/models/models.py", line 70, in web_save
self.write(vals)
File "/usr/lib/python3/dist-packages/odoo/addons/base_automation/models/base_automation.py", line 802, in write
automation._process(records, domain_post=domain_post)
File "/usr/lib/python3/dist-packages/odoo/addons/base_automation/models/base_automation.py", line 728, in _process
action.with_context(**ctx).run()
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions.py", line 995, in run
res = runner(run_self, eval_context=eval_context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions.py", line 827, in _run_action_code_multi
safe_eval(self.code.strip(), eval_context, mode="exec", nocopy=True, filename=str(self)) # nocopy allows to return 'action'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/tools/safe_eval.py", line 411, in safe_eval
raise ValueError('%r while evaluating\n%r' % (e, expr))
ValueError: ValueError("Invalid field 'signing_order' on model 'sign.request'") while evaluating
'_logger.info("Rule 1: Offer Letter script triggered for Applicant ID %s", record.id)\n\ntemplate = env[\'sign.template\'].search([(\'name\', \'=\', \'UAE Employee Employment Contract.pdf\')], limit=1)\nif not template:\n raise UserError("Offer Letter template not found.")\n\nroles = template.sign_item_ids.mapped(\'responsible_id\')\n\nemployee_email = record.email_from\nemployer_email = record.user_id.partner_id.email if record.user_id and record.user_id.partner_id else None\n\nif not (template and roles and employee_email and employer_email):\n raise UserError("Missing template, roles, or required emails. Offer letter generation failed.")\n\n# Prefill Data\ncurrent_date = record.create_date.strftime(\'%d/%m/%Y\') if record.create_date else \'\'\nformatted_start_date = \'\'\nif record.x_studio_start_date:\n try:\n formatted_start_date = record.x_studio_start_date.strftime(\'%d/%m/%Y\')\n except Exception:\n formatted_start_date = str(record.x_studio_start_date)\n\nvalue_dict = {\n \'Date\': current_date,\n \'Job Title\': record.x_studio_job_title or \'\',\n \'Start Date\': formatted_start_date,\n \'Work Location\': record.x_studio_country_of_employment or \'\',\n \'Salary\': record.x_studio_monthly_daily_hourly_rate or \'\',\n \'Medical\': record.x_studio_medical_insurance_provided or \'\',\n \'Employment Type\': record.x_studio_employment_type or \'\',\n \'Name\': record.x_studio_preferred_name or \'\',\n}\n\nprefill_values = []\nfor item in template.sign_item_ids:\n if item.name in value_dict:\n prefill_values.append((0, 0, {\n \'sign_item_id\': item.id,\n \'value\': value_dict[item.name],\n }))\n\n_logger.info("Rule 1: Prepared sign request items for Applicant ID %s", record.id)\n\nrequest_items = []\nfor role in roles:\n if role.name == \'Employer\':\n request_items.append((0, 0, {\n \'role_id\': role.id,\n \'partner_id\': record.user_id.partner_id.id if record.user_id and record.user_id.partner_id else False,\n \'signer_email\': employer_email,\n \'sign_item_value_ids\': prefill_values,\n \'state\': \'sent\', # Employer receives immediately\n }))\n elif role.name == \'Employee\':\n request_items.append((0, 0, {\n \'role_id\': role.id,\n \'partner_id\': record.partner_id.id if record.partner_id else False,\n \'signer_email\': employee_email,\n \'state\': \'waiting\', # Employee won\'t receive until employer signs\n }))\n\nif not request_items:\n raise UserError("No signing roles found in the offer letter template.")\n\n# Create Sign Request with Sequential Signing\nsign_request = env[\'sign.request\'].create({\n \'template_id\': template.id,\n \'reference\': f"Offer-{record.id}",\n \'subject\': f"Employment Contract - {record.partner_name or record.name}",\n \'request_item_ids\': request_items,\n \'signing_order\': \'sequential\', # Force sequential signing\n})\n\n_logger.info("Rule 1: Offer Letter sent successfully for Applicant ID %s", record.id)'

The above server error caused the following client error:
RPC_ERROR: Odoo Server Error
RPC_ERROR
at makeErrorFromResponse (https://crm.codification.io/web/assets/9547b44/web.assets_web.min.js:3141:163)
at XMLHttpRequest.<anonymous> (https://crm.codification.io/web/assets/9547b44/web.assets_web.min.js:3146:13)

Autor

Can someone please help?

Mejor respuesta

Hello Faisal,

Your current automation script creates a sign request where both employer and employee receive the document simultaneously, which leads to the blank document problem when the employee opens it before the employer fills their section.

Key Problems Identified:
  1. Simultaneous Signing: Both parties receive the document at the same time
  2. Data Visibility: Employee sees incomplete document before employer fills it
  3. No Signing Sequence: No enforced order of signing

Solution: Implement Sequential Signing

You need to modify your script to:

  1. Set up sequential signing (employer first)
  2. Delay employee notification until employer completes their part
  3. Ensure data is pre-filled before employee sees document
Modified Script:

python

_logger.info("Rule 1: Offer Letter script triggered for Applicant ID %s", record.id)

template = env['sign.template'].search([('name', '=', 'UAE Employee Employment Contract.pdf')], limit=1)
if not template:
    raise UserError("Offer Letter template not found.")

roles = template.sign_item_ids.mapped('responsible_id')

employee_email = record.email_from
employer_email = record.user_id.partner_id.email if record.user_id and record.user_id.partner_id else None

if not (template and roles and employee_email and employer_email):
    raise UserError("Missing template, roles, or required emails. Offer letter generation failed.")

# Prefill Data
current_date = record.create_date.strftime('%d/%m/%Y') if record.create_date else ''
formatted_start_date = ''
if record.x_studio_start_date:
    try:
        formatted_start_date = record.x_studio_start_date.strftime('%d/%m/%Y')
    except Exception:
        formatted_start_date = str(record.x_studio_start_date)

value_dict = {
    'Date': current_date,
    'Job Title': record.x_studio_job_title or '',
    'Start Date': formatted_start_date,
    'Work Location': record.x_studio_country_of_employment or '',
    'Salary': record.x_studio_monthly_daily_hourly_rate or '',
    'Medical': record.x_studio_medical_insurance_provided or '',
    'Employment Type': record.x_studio_employment_type or '',
    'Name': record.x_studio_preferred_name or '',
}

prefill_values = []
for item in template.sign_item_ids:
    if item.name in value_dict:
        prefill_values.append((0, 0, {
            'sign_item_id': item.id,
            'value': value_dict[item.name],
        }))

_logger.info("Rule 1: Prepared sign request items for Applicant ID %s", record.id)

request_items = []
for role in roles:
    if role.name == 'Employer':
        request_items.append((0, 0, {
            'role_id': role.id,
            'partner_id': record.user_id.partner_id.id if record.user_id and record.user_id.partner_id else False,
            'signer_email': employer_email,
            'sign_item_value_ids': prefill_values,
            'state': 'sent',  # Employer receives immediately
        }))
    elif role.name == 'Employee':
        request_items.append((0, 0, {
            'role_id': role.id,
            'partner_id': record.partner_id.id if record.partner_id else False,
            'signer_email': employee_email,
            'state': 'waiting',  # Employee won't receive until employer signs
        }))

if not request_items:
    raise UserError("No signing roles found in the offer letter template.")

# Create Sign Request with Sequential Signing
sign_request = env['sign.request'].create({
    'template_id': template.id,
    'reference': f"Offer-{record.id}",
    'subject': f"Employment Contract - {record.partner_name or record.name}",
    'request_item_ids': request_items,
    'signing_order': 'sequential',  # Force sequential signing
})

_logger.info("Rule 1: Offer Letter sent successfully for Applicant ID %s", record.id)
Key Changes Made:
  1. Added signing_order: 'sequential': Forces employer to sign before employee
  2. Set employee state to 'waiting': Employee won't receive notification until employer completes
  3. Set employer state to 'sent': Employer receives immediately

Maintained all prefill data: Still pre-populates for employer to review

🚀 Did This Solve Your Problem?

If this answer helped you save time, money, or frustration, consider:

✅ Upvoting (👍) to help others find it faster

✅ Marking as "Best Answer" if it resolved your issue

Your feedback keeps the Odoo community strong! 💪

(Need further customization? Drop a comment—I’m happy to refine the solution!)

Avatar
Descartar
Autor Mejor respuesta
_logger.info("Rule 1: Offer Letter script triggered for Applicant ID %s", record.id)

template = env['sign.template'].search([('name', '=', 'UAE Employee Employment Contract.pdf')], limit=1)
if not template:
    raise UserError("Offer Letter template not found.")

roles = template.sign_item_ids.mapped('responsible_id')

employee_email = record.email_from
employer_email = record.user_id.partner_id.email if record.user_id and record.user_id.partner_id else None

if not (template and roles and employee_email and employer_email):
    raise UserError("Missing template, roles, or required emails. Offer letter generation failed.")

# Prefill Data
current_date = record.create_date.strftime('%d/%m/%Y') if record.create_date else ''
formatted_start_date = ''
if record.x_studio_start_date:
    try:
        formatted_start_date = record.x_studio_start_date.strftime('%d/%m/%Y')
    except Exception:
        formatted_start_date = str(record.x_studio_start_date)

value_dict = {
    'Date': current_date,
    'Job Title': record.x_studio_job_title or '',
    'Start Date': formatted_start_date,
    'Work Location': record.x_studio_country_of_employment or '',
    'Salary': record.x_studio_monthly_daily_hourly_rate or '',
    'Medical': record.x_studio_medical_insurance_provided or '',
    'Employment Type': record.x_studio_employment_type or '',
    'Name': record.x_studio_preferred_name or '',
}

prefill_values = []
for item in template.sign_item_ids:
    if item.name in value_dict:
        prefill_values.append((0, 0, {
            'sign_item_id': item.id,
            'value': value_dict[item.name],
        }))

_logger.info("Rule 1: Prepared sign request items for Applicant ID %s", record.id)

request_items = []
for role in roles:
    if role.name == 'Employer':
        request_items.append((0, 0, {
            'role_id': role.id,
            'partner_id': record.user_id.partner_id.id if record.user_id and record.user_id.partner_id else False,
            'signer_email': employer_email,
            'sign_item_value_ids': prefill_values,  # Employer can review and edit these fields
        }))
    elif role.name == 'Employee':
        request_items.append((0, 0, {
            'role_id': role.id,
            'partner_id': record.partner_id.id if record.partner_id else False,
            'signer_email': employee_email,
        }))

if not request_items:
    raise UserError("No signing roles found in the offer letter template.")

# Create Sign Request with Sequential Signing (Employer first)
env['sign.request'].create({
    'template_id': template.id,
    'reference': f"Offer-{record.id}",
    'subject': f"Employment Contract - {record.partner_name or record.name}",
    'request_item_ids': request_items,
})

_logger.info("Rule 1: Offer Letter sent successfully for Applicant ID %s", record.id)


This is the script I am using, Can I know that do I need to make any changes here

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
jul 24
1088
1
oct 24
1164
3
may 25
2292
0
mar 23
1700
1
dic 22
3262