refactor: migrate Odoo 19 view components, update payment reference fields, and simplify account domain constraints
This commit is contained in:
parent
4a64d2b73c
commit
bfaacbfe7c
@ -90,7 +90,7 @@ class AccountPayment(models.Model):
|
||||
if hr_expense_class and self._context.get('skip_expense_lock'):
|
||||
return super(hr_expense_class, self).write(vals)
|
||||
|
||||
if self.expense_sheet_id and self.state == 'draft':
|
||||
if self.expense_ids and self.state == 'draft':
|
||||
return super(AccountPayment, self.with_context(skip_expense_lock=True)).write(vals)
|
||||
return super().write(vals)
|
||||
|
||||
@ -103,10 +103,10 @@ class AccountPayment(models.Model):
|
||||
res = super().action_cancel()
|
||||
|
||||
for payment in self:
|
||||
if payment.expense_sheet_id:
|
||||
payment.expense_sheet_id.invalidate_recordset(['state'])
|
||||
if payment.realization_id and payment.realization_id.expense_sheet_id:
|
||||
payment.realization_id.expense_sheet_id.invalidate_recordset(['state'])
|
||||
if payment.expense_ids:
|
||||
payment.expense_ids.invalidate_recordset(['state'])
|
||||
if payment.realization_id and payment.realization_id.expense_id:
|
||||
payment.realization_id.expense_id.invalidate_recordset(['state'])
|
||||
return res
|
||||
|
||||
def action_draft(self):
|
||||
@ -118,10 +118,10 @@ class AccountPayment(models.Model):
|
||||
res = super().action_draft()
|
||||
|
||||
for payment in self:
|
||||
if payment.expense_sheet_id:
|
||||
payment.expense_sheet_id.invalidate_recordset(['state'])
|
||||
if payment.realization_id and payment.realization_id.expense_sheet_id:
|
||||
payment.realization_id.expense_sheet_id.invalidate_recordset(['state'])
|
||||
if payment.expense_ids:
|
||||
payment.expense_ids.invalidate_recordset(['state'])
|
||||
if payment.realization_id and payment.realization_id.expense_id:
|
||||
payment.realization_id.expense_id.invalidate_recordset(['state'])
|
||||
return res
|
||||
|
||||
def _seek_for_lines(self):
|
||||
|
||||
@ -207,7 +207,7 @@ class HrExpense(models.Model):
|
||||
for expense in self:
|
||||
if expense.account_move_id:
|
||||
move = expense.sudo().account_move_id
|
||||
payment = move.payment_id
|
||||
payment = move.origin_payment_id
|
||||
if payment:
|
||||
if payment.state in ('posted', 'draft'):
|
||||
payment.action_cancel()
|
||||
|
||||
@ -7,14 +7,14 @@ class ProductTemplate(models.Model):
|
||||
'account.account',
|
||||
string="Expense Account (Employee)",
|
||||
company_dependent=True,
|
||||
domain="[('account_type', 'not in', ('asset_receivable', 'liability_payable', 'asset_cash', 'liability_credit_card')), ('deprecated', '=', False)]",
|
||||
domain="[('account_type', 'not in', ('asset_receivable', 'liability_payable', 'asset_cash', 'liability_credit_card'))]",
|
||||
help="Account used for expenses paid by the employee (to be reimbursed)."
|
||||
)
|
||||
property_account_expense_company_id = fields.Many2one(
|
||||
'account.account',
|
||||
string="Expense Account (Company)",
|
||||
company_dependent=True,
|
||||
domain="[('account_type', 'not in', ('asset_receivable', 'liability_payable', 'asset_cash', 'liability_credit_card')), ('deprecated', '=', False)]",
|
||||
domain="[('account_type', 'not in', ('asset_receivable', 'liability_payable', 'asset_cash', 'liability_credit_card'))]",
|
||||
help="Account used for expenses paid by the company."
|
||||
)
|
||||
receipt_due_days = fields.Integer(
|
||||
|
||||
@ -5,14 +5,14 @@
|
||||
<field name="name">hr.expense.realization.view.tree</field>
|
||||
<field name="model">hr.expense.realization</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Expense Realization">
|
||||
<list string="Expense Realization">
|
||||
<field name="name"/>
|
||||
<field name="date"/>
|
||||
<field name="employee_id"/>
|
||||
<field name="expense_id"/>
|
||||
<field name="total_amount" sum="Total Amount"/>
|
||||
<field name="state" widget="badge" decoration-info="state == 'draft'" decoration-warning="state == 'confirmed'" decoration-success="state == 'posted'"/>
|
||||
</tree>
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@ -90,14 +90,14 @@
|
||||
<notebook>
|
||||
<page string="Receipts" name="receipt_lines">
|
||||
<field name="line_ids" readonly="state == 'posted'">
|
||||
<tree editable="bottom">
|
||||
<list editable="bottom">
|
||||
<field name="description"/>
|
||||
<field name="amount" sum="Total"/>
|
||||
<field name="attachment_id" filename="attachment_name" widget="binary"/>
|
||||
<field name="attachment_name" column_invisible="1"/>
|
||||
<field name="counterpart_account_id" groups="account.group_account_invoice" required="parent.state == 'confirmed'"/>
|
||||
<field name="move_id" groups="account.group_account_invoice" widget="many2one_clickable" readonly="1" invisible="not move_id"/>
|
||||
</tree>
|
||||
</list>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Notes" name="notes">
|
||||
@ -114,33 +114,11 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Realization Search View -->
|
||||
<record id="hr_expense_realization_view_search" model="ir.ui.view">
|
||||
<field name="name">hr.expense.realization.view.search</field>
|
||||
<field name="model">hr.expense.realization</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Realization">
|
||||
<field name="name"/>
|
||||
<field name="employee_id"/>
|
||||
<field name="expense_id"/>
|
||||
<filter string="Draft" name="draft" domain="[('state', '=', 'draft')]"/>
|
||||
<filter string="Confirmed" name="confirmed" domain="[('state', '=', 'confirmed')]"/>
|
||||
<filter string="Posted" name="posted" domain="[('state', '=', 'posted')]"/>
|
||||
<group expand="0" string="Group By">
|
||||
<filter string="Employee" name="group_employee" context="{'group_by': 'employee_id'}"/>
|
||||
<filter string="Status" name="group_state" context="{'group_by': 'state'}"/>
|
||||
<filter string="Date" name="group_date" context="{'group_by': 'date'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Realization Action -->
|
||||
<record id="action_hr_expense_realization" model="ir.actions.act_window">
|
||||
<field name="name">Realization Report</field>
|
||||
<field name="res_model">hr.expense.realization</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="search_view_id" ref="hr_expense_realization_view_search"/>
|
||||
<field name="view_mode">list,form</field>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_smiling_face">
|
||||
Create a new Realization Report
|
||||
|
||||
@ -106,7 +106,7 @@
|
||||
<field name="model">hr.expense</field>
|
||||
<field name="inherit_id" ref="hr_expense.hr_expense_view_search"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//filter[@name='my_expenses']" position="after">
|
||||
<xpath expr="//filter[@name='my_open_expenses']" position="after">
|
||||
<separator/>
|
||||
<filter string="Wait Post" name="filter_wait_post" domain="[('state', '=', 'wait_post')]"/>
|
||||
<filter string="Overdue Receipts" name="filter_receipt_overdue" domain="[('receipt_overdue', '=', True), ('receipt_received', '=', False)]"/>
|
||||
@ -145,7 +145,7 @@
|
||||
|
||||
<!-- Update Actions to include Wait Post in SearchPanel -->
|
||||
<record id="hr_expense.hr_expense_actions_my_all" model="ir.actions.act_window">
|
||||
<field name="context">{ 'searchpanel_default_state': ["draft", "submitted", "approved", "posted", "wait_post", "paid"], 'search_default_my_expenses': 1 }</field>
|
||||
<field name="context">{ 'searchpanel_default_state': ["draft", "submitted", "approved", "posted", "wait_post", "paid"], 'search_default_my_open_expenses': 1 }</field>
|
||||
</record>
|
||||
|
||||
<record id="hr_expense.hr_expense_actions_all" model="ir.actions.act_window">
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="account.product_template_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//group[@name='payables']" position="inside">
|
||||
<xpath expr="//field[@name='property_account_expense_id']" position="after">
|
||||
<field name="property_account_expense_employee_id" invisible="not can_be_expensed"/>
|
||||
<field name="property_account_expense_company_id" invisible="not can_be_expensed"/>
|
||||
<field name="receipt_due_days" invisible="not can_be_expensed"/>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user