Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions advance_payment/models/advance_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ class AdvancePayment(models.Model):
compute="_compute_reference_state",
)

can_edit = fields.Boolean(compute="_compute_can_edit")

@api.depends("state")
def _compute_can_edit(self):
for rec in self:
rec.can_edit = rec.state == "draft"

is_requester = fields.Boolean(compute="_compute_is_requester")

@api.depends("requested_by")
Expand Down
9 changes: 5 additions & 4 deletions advance_payment/views/advance_payment_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
statusbar_visible="draft,submitted,approved,in_progress,done" />
</header>
<sheet>
<field name="can_edit" invisible="1"/>
<div name="button_box" class="oe_button_box">
<button name="action_view_payments"
type="object"
Expand Down Expand Up @@ -159,13 +160,13 @@
</group>
<group string="มิติทางบัญชี">
<field name="department_analytic_id"
attrs="{'readonly': [('state', '!=', 'draft')]}" />
attrs="{'readonly': [('can_edit', '=', False)]}" />
<field name="source_analytic_id"
attrs="{'readonly': [('state', '!=', 'draft')]}" />
attrs="{'readonly': [('can_edit', '=', False)]}" />
<field name="fund_analytic_id"
attrs="{'readonly': [('state', '!=', 'draft')]}" />
attrs="{'readonly': [('can_edit', '=', False)]}" />
<field name="activity_analytic_id"
attrs="{'readonly': [('state', '!=', 'draft')]}" />
attrs="{'readonly': [('can_edit', '=', False)]}" />
</group>
<group string="สรุปยอดเงิน" attrs="{'invisible': [('state', '=', 'draft')]}">
<field name="amount_used" />
Expand Down
7 changes: 7 additions & 0 deletions agx_sarabun/models/sarabun_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ class SarabunDocument(models.Model):
default="draft",
)

can_edit = fields.Boolean(compute="_compute_can_edit")

@api.depends("state")
def _compute_can_edit(self):
for rec in self:
rec.can_edit = rec.state == "draft"

# === Routing ===
route_template_id = fields.Many2one(
comodel_name="sarabun.route.template",
Expand Down
11 changes: 6 additions & 5 deletions agx_sarabun/views/sarabun_document_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<field name="state" widget="statusbar" statusbar_visible="draft,sent,completed"/>
</header>
<sheet>
<field name="can_edit" invisible="1"/>
<div class="oe_button_box" name="button_box">
<button class="oe_stat_button" type="object" name="open_preview" icon="fa-search-plus" string="เปิดเอกสาร" />
</div>
Expand Down Expand Up @@ -143,18 +144,18 @@
<page name="content" string="Content" attrs="{'invisible': [('has_delegated_report', '=', True)]}">
<field name="content" placeholder="Enter document content..." class="oe-bordered-editor" options="{'codeview': true, 'dynamic_placeholder': true}" />
<label for="attachment_ids" string="Attachments"/>
<field name="attachment_ids" widget="many2many_binary" attrs="{'readonly': [('state', 'not in', ['draft'])]}" class="w-100" />
<field name="attachment_ids" widget="many2many_binary" attrs="{'readonly': [('can_edit', '=', False)]}" class="w-100" />
</page>
<!-- Report Preview page - shown when origin has delegated report -->
<page name="report_preview" string="Document Preview" attrs="{'invisible': [('has_delegated_report', '=', False)]}">
<field name="report_preview_url" widget="iframe_viewer" nolabel="1"/>
</page>
<page string="Routing" name="routing">
<group>
<field name="route_template_id" options="{'no_create': True}" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
<field name="route_template_id" options="{'no_create': True}" attrs="{'readonly': [('can_edit', '=', False)]}"/>
</group>
<!-- Route Definition (editable in draft, readonly with status after sent) -->
<field name="routing_line_ids" attrs="{'readonly': [('state', '!=', 'draft')]}">
<field name="routing_line_ids" attrs="{'readonly': [('can_edit', '=', False)]}">
<tree string="Routing" editable="bottom" decoration-muted="recipient_state == 'waiting'" decoration-info="recipient_state == 'new'" decoration-success="recipient_state in ('acknowledged', 'approved')" decoration-danger="recipient_state == 'rejected'">
<field name="sequence" widget="handle"/>
<field name="routing_type"/>
Expand All @@ -174,7 +175,7 @@
<page string="References" name="references">
<span />
<group string="Referenced Documents">
<field name="referenced_document_ids" colspan="2" nolabel="1" attrs="{'readonly': [('state', 'not in', ['draft'])]}">
<field name="referenced_document_ids" colspan="2" nolabel="1" attrs="{'readonly': [('can_edit', '=', False)]}">
<tree>
<field name="name"/>
<field name="subject"/>
Expand All @@ -184,7 +185,7 @@
</field>
</group>
<group string="Other References">
<field name="reference_ids" colspan="2" nolabel="1" attrs="{'readonly': [('state', 'not in', ['draft'])]}">
<field name="reference_ids" colspan="2" nolabel="1" attrs="{'readonly': [('can_edit', '=', False)]}">
<tree editable="bottom">
<field name="res_model"/>
<field name="res_id"/>
Expand Down
7 changes: 7 additions & 0 deletions budget/models/budget_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ class BudgetTransfer(models.Model):
default="draft",
)

can_edit = fields.Boolean(compute="_compute_can_edit")

@api.depends("state")
def _compute_can_edit(self):
for rec in self:
rec.can_edit = rec.state == "draft"

# Transfer Details
transfer_type = fields.Selection(
selection=[
Expand Down
13 changes: 7 additions & 6 deletions budget/views/budget_transfer_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</header>

<sheet>
<field name="can_edit" invisible="1"/>
<div class="oe_button_box" name="button_box">
<button name="%(action_budget_move)d" type="action" class="oe_stat_button" icon="fa-exchange" attrs="{'invisible': [('budget_move_ids', '=', [])]}" context="{'search_default_transfer_id': id}">
<field name="budget_move_ids" widget="statinfo" string="Budget Moves"/>
Expand All @@ -33,10 +34,10 @@

<group>
<group name="transfer_info">
<field name="date" attrs="{'readonly': [('state', 'not in', ['draft'])]}"/>
<field name="date" attrs="{'readonly': [('can_edit', '=', False)]}"/>
<field name="transfer_type"/>
<field name="department_analytic_id" attrs="{'readonly': [('state', 'not in', ['draft'])]}"/>
<field name="source_analytic_id" attrs="{'readonly': [('state', 'not in', ['draft'])]}"/>
<field name="department_analytic_id" attrs="{'readonly': [('can_edit', '=', False)]}"/>
<field name="source_analytic_id" attrs="{'readonly': [('can_edit', '=', False)]}"/>
</group>
<group name="meta_info">
<field name="user_id"/>
Expand All @@ -60,15 +61,15 @@
</div>

<group name="transfer_reason" colspan="8">
<field name="reason" placeholder="Please provide detailed justification for this budget transfer..." attrs="{'readonly': [('state', 'not in', ['draft'])]}" colspan="2"/>
<field name="reason" placeholder="Please provide detailed justification for this budget transfer..." attrs="{'readonly': [('can_edit', '=', False)]}" colspan="2"/>
</group>

<!-- Transfer Lines -->
<notebook>
<page name="transfer_lines" string="Transfer Details">
<group attrs="{'invisible': [('state', 'not in', ['draft'])]}">
<separator string="Transfer FROM (Source)" />
<field name="from_line_ids" nolabel="1" colspan="2" attrs="{'readonly': [('state', 'not in', ['draft'])]}">
<field name="from_line_ids" nolabel="1" colspan="2" attrs="{'readonly': [('can_edit', '=', False)]}">
<tree decoration-info="1" create="1" delete="1">
<field name="sequence" widget="handle"/>
<field name="budget_account_id" required="1"/>
Expand All @@ -84,7 +85,7 @@
</tree>
</field>
<separator string="Transfer TO (Destination)" />
<field name="to_line_ids" nolabel="1" colspan="2" attrs="{'readonly': [('state', 'not in', ['draft'])]}">
<field name="to_line_ids" nolabel="1" colspan="2" attrs="{'readonly': [('can_edit', '=', False)]}">
<tree decoration-success="1" create="1" delete="1">
<field name="sequence" widget="handle"/>
<field name="budget_account_id" required="1"/>
Expand Down
7 changes: 7 additions & 0 deletions budget_appropriation/models/budget_appropriation.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ class BudgetAppropriation(models.Model):
tracking=True,
default="draft",
)
can_edit = fields.Boolean(compute="_compute_can_edit")

@api.depends("state")
def _compute_can_edit(self):
for rec in self:
rec.can_edit = rec.state == "draft"

account_fiscal_year_id = fields.Many2one(
comodel_name="account.fiscal.year",
string="ปีงบประมาณ",
Expand Down
5 changes: 3 additions & 2 deletions budget_appropriation/views/budget_appropriation_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<field name="company_id" invisible="1" />
<field name="budget_type" invisible="1" />
<sheet>
<field name="can_edit" invisible="1"/>
<div class="oe_button_box" name="button_box">
<button class="oe_stat_button" type="object" name="open_record_url"
icon="fa-external-link" string="Preview" />
Expand Down Expand Up @@ -75,7 +76,7 @@
<page name="line_ids" string="Appropriation Lines">
<separator string="จัดสรรงบประมาณ" />
<group>
<field nolabel="1" colspan="2" name="line_ids" style="max-width: 100%; display: block;" attrs="{'readonly': [('state', 'in', ['review', 'posted', 'cancel'])]}" widget="budget_appropriation_line">
<field nolabel="1" colspan="2" name="line_ids" style="max-width: 100%; display: block;" attrs="{'readonly': [('can_edit', '=', False)]}" widget="budget_appropriation_line">
<tree limit="1000">
<field name="id" readonly="1" optional="show" />
<field name="appropriation_id" invisible="1" />
Expand All @@ -95,7 +96,7 @@
</group>
<group attrs="{'invisible': [('budget_type', '!=', 'revenue')]}">
<separator string="หัก" />
<field nolabel="1" colspan="2" name="deduct_line_ids" style="max-width: 100%; display: block;" attrs="{'readonly': [('state', 'in', ['review', 'posted', 'cancel'])]}" widget="budget_appropriation_line" context="{'default_deduct': True}">
<field nolabel="1" colspan="2" name="deduct_line_ids" style="max-width: 100%; display: block;" attrs="{'readonly': [('can_edit', '=', False)]}" widget="budget_appropriation_line" context="{'default_deduct': True}">
<tree limit="1000">
<field name="id" readonly="1" optional="show" />
<field name="appropriation_id" invisible="1" />
Expand Down
6 changes: 6 additions & 0 deletions hr_recruitment_kmitl/models/hr_onboarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ class HrOnboarding(models.Model):
default="draft",
tracking=True,
)
can_edit = fields.Boolean(compute="_compute_can_edit")
submitted_date = fields.Datetime(readonly=True, tracking=True)

@api.depends("state")
def _compute_can_edit(self):
for rec in self:
rec.can_edit = rec.state == "draft"

# Blood type
blood_type = fields.Selection(
[("a", "A"), ("b", "B"), ("ab", "AB"), ("o", "O")], tracking=True
Expand Down
21 changes: 11 additions & 10 deletions hr_recruitment_kmitl/views/hr_onboarding_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
/>
</header>
<sheet>
<field name="can_edit" invisible="1"/>
<div class="oe_title">
<h1>
<field name="name" readonly="1" />
Expand All @@ -84,7 +85,7 @@
<group>
<field
name="applicant_id"
attrs="{'readonly': [('state', '=', 'submitted')]}"
attrs="{'readonly': [('can_edit', '=', False)]}"
/>
</group>
<group>
Expand All @@ -93,7 +94,7 @@
<group>
<field
name="blood_type"
attrs="{'readonly': [('state', '=', 'submitted')]}"
attrs="{'readonly': [('can_edit', '=', False)]}"
/>
<field name="can_start_on_time" />
<field name="starting_date" />
Expand All @@ -109,18 +110,18 @@
name="starting_date_note"
nolabel="1"
placeholder="Notes..."
attrs="{'readonly': [('state', '=', 'submitted')]}"
attrs="{'readonly': [('can_edit', '=', False)]}"
/>
</group>
<group attrs="{'readonly': [('state', '=', 'submitted')]}">
<group attrs="{'readonly': [('can_edit', '=', False)]}">

</group>
</group>
<notebook>
<page string="Family" name="family">
<field
name="family_member_ids"
attrs="{'readonly': [('state', '=', 'submitted')]}"
attrs="{'readonly': [('can_edit', '=', False)]}"
>
<tree editable="bottom">
<field name="relation_id" />
Expand All @@ -137,7 +138,7 @@
</field>
</page>
<page string="Royal Decoration" name="royal_decoration">
<group attrs="{'readonly': [('state', '=', 'submitted')]}">
<group attrs="{'readonly': [('can_edit', '=', False)]}">
<group>
<field name="royal_decoration_id" />
<field name="royal_decoration_level" />
Expand All @@ -157,7 +158,7 @@
</group>
</page>
<page string="Benefits" name="benefits">
<group attrs="{'readonly': [('state', '=', 'submitted')]}">
<group attrs="{'readonly': [('can_edit', '=', False)]}">
<group string="Health Insurance">
<field
name="health_employee_file"
Expand Down Expand Up @@ -187,7 +188,7 @@
/>
</group>
</group>
<group attrs="{'readonly': [('state', '=', 'submitted')]}">
<group attrs="{'readonly': [('can_edit', '=', False)]}">
<group string="Provident Fund">
<field
name="provident_fund_file"
Expand Down Expand Up @@ -219,7 +220,7 @@
</group>
</page>
<page string="Confirmation" name="confirmation">
<group attrs="{'readonly': [('state', '=', 'submitted')]}">
<group attrs="{'readonly': [('can_edit', '=', False)]}">
<group string="Background Check &amp; Bank">
<field name="background_check_location_type" />
<field name="krungthai_bank_account" />
Expand All @@ -240,7 +241,7 @@
/>
</group>
</group>
<group attrs="{'readonly': [('state', '=', 'submitted')]}">
<group attrs="{'readonly': [('can_edit', '=', False)]}">
<group string="PDPA &amp; Final Confirmation">
<field name="pdpa_consent" />
<field name="final_confirm" />
Expand Down
Loading