25 lines
1.1 KiB
Python
25 lines
1.1 KiB
Python
import re
|
|
|
|
with open('addons/education_lms/security/security.xml', 'r') as f:
|
|
text = f.read()
|
|
|
|
# Replace the Course rule domain
|
|
text = re.sub(
|
|
r'<record id="rule_lms_course_student" model="ir.rule">.*?<field name="domain_force">\[.*?\]</field>',
|
|
"""<record id="rule_lms_course_student" model="ir.rule">
|
|
<field name="name">Student Course Access</field>
|
|
<field name="model_id" ref="model_education_lms_course"/>
|
|
<field name="domain_force">[
|
|
('state', 'in', ['published', 'closed']),
|
|
('program_id', 'in', user.student_ids.mapped('program_id').ids),
|
|
('academic_year_id', 'in', user.student_ids.mapped('academic_year_id').ids),
|
|
'|', ('term_id', '=', False), ('term_id', 'in', user.student_ids.mapped('academic_term_id').ids),
|
|
'|', ('batch_id', '=', False), ('batch_id', 'in', user.student_ids.mapped('batch_id').ids),
|
|
]</field>""",
|
|
text,
|
|
flags=re.DOTALL
|
|
)
|
|
|
|
with open('addons/education_lms/security/security.xml', 'w') as f:
|
|
f.write(text)
|