[IMP] *: replace the dropdown actions with controlpanel buttons

* calender_sms, hr_expense, sale_project

PURPOSE

Enable the framework to define some of actions in the controlpanel,
as buttons similar to the 'create/edit/discard' buttons.

SPECIFICATIONS

Replace the below-mentioned dropdown actions with controlpanel buttons

-  'send sms to attendees' in Calendar > Calendar
-  'approve report' in Expenses > Expense Reports > To approve
-  'post entries' in Expenses > Expense Reports > To post
-  'register payment' in Expenses > Expenses Reports > To pay
-  'create invoice' in Field Service > All Tasks > To Invoice

LINKS

PR https://github.com/odoo/odoo/pull/57830
Task-2300426

closes odoo/odoo#57830

Related: odoo/enterprise#13272
Related: odoo/upgrade#1785
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
Kamesh Patel
2020-09-21 06:25:29 +00:00
parent 6ef622772f
commit 2239fff916
4 changed files with 25 additions and 69 deletions
+14 -1
View File
@@ -11,7 +11,20 @@
'default_composition_mode': 'comment',
'default_res_id': active_id,
}</field>
<field name="binding_model_id" ref="model_calendar_event"/>
</record>
<record id="view_calendar_event_tree_inherited" model="ir.ui.view">
<field name="name">calendar.event.tree.calendar_sms</field>
<field name="model">calendar.event</field>
<field name="inherit_id" ref="calendar.view_calendar_event_tree"/>
<field name="arch" type="xml">
<xpath expr="//tree" position="inside">
<header>
<button name="%(calendar_event_act_window_sms_composer_single)d" type="action"
string="Send SMS to attendees"/>
</header>
</xpath>
</field>
</record>
</odoo>
+11 -39
View File
@@ -570,6 +570,17 @@
<field name="model">hr.expense.sheet</field>
<field name="arch" type="xml">
<tree string="Expense Reports" multi_edit="1" js_class="hr_expense_tree_dashboard_upload" sample="1">
<header>
<button name="approve_expense_sheets" string="Approve Report" type="object"
groups="hr_expense.group_hr_expense_team_approver"
invisible="not context.get('search_default_submitted',0)"/>
<button name="action_sheet_move_create" string="Post Entries" type="object"
groups="account.group_account_invoice,hr_expense.group_hr_expense_manager"
invisible="not context.get('search_default_to_post',0)"/>
<button name="action_register_payment" string="Register Payment" type="object"
groups="account.group_account_invoice,hr_expense.group_hr_expense_manager"
invisible="not context.get('search_default_approved',0)"/>
</header>
<field name="employee_id" widget="many2one_avatar_employee"/>
<field name="accounting_date" optional="show" groups="account.group_account_manager"/>
<field name="create_date" optional="hide"/>
@@ -1053,45 +1064,6 @@ if records:
</field>
</record>
<record id="hr_expense_sheet_approve_action_server" model="ir.actions.server">
<field name="name">Approve Report</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="model_hr_expense_sheet"/>
<field name="binding_model_id" ref="model_hr_expense_sheet"/>
<field name="binding_view_types">list</field>
<field name="state">code</field>
<field name="code">
if records:
action = records.approve_expense_sheets()
</field>
</record>
<record id="hr_expense_sheet_post_action_server" model="ir.actions.server">
<field name="name">Post Entries</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="model_hr_expense_sheet"/>
<field name="binding_model_id" ref="model_hr_expense_sheet"/>
<field name="binding_view_types">list</field>
<field name="state">code</field>
<field name="code">
if records:
action = records.action_sheet_move_create()
</field>
</record>
<record id="action_expense_sheet_register_payment" model="ir.actions.server">
<field name="name">Register Payment</field>
<field name="groups_id" eval="[(4, ref('account.group_account_invoice'))]"/>
<field name="model_id" ref="hr_expense.model_hr_expense_sheet"/>
<field name="binding_model_id" ref="hr_expense.model_hr_expense_sheet"/>
<field name="binding_view_types">list</field>
<field name="state">code</field>
<field name="code">
if records:
action = records.action_register_payment()
</field>
</record>
<menuitem id="menu_hr_expense_root" name="Expenses" sequence="100" web_icon="hr_expense,static/description/icon.png"/>
<menuitem id="menu_hr_expense_my_expenses" name="My Expenses" sequence="1" parent="menu_hr_expense_root" groups="base.group_user"/>
-17
View File
@@ -126,23 +126,6 @@ class ProjectTask(models.Model):
operator_new = 'not inselect'
return [('sale_order_id', operator_new, (query, ()))]
def action_create_invoice(self):
# ensure the SO exists before invoicing, then confirm it
so_to_confirm = self.filtered(
lambda task: task.sale_order_id and task.sale_order_id.state in ['draft', 'sent']
).mapped('sale_order_id')
so_to_confirm.action_confirm()
# redirect create invoice wizard (of the Sales Order)
action = self.env["ir.actions.actions"]._for_xml_id("sale.action_view_sale_advance_payment_inv")
context = literal_eval(action.get('context', "{}"))
context.update({
'active_id': self.sale_order_id.id if len(self) == 1 else False,
'active_ids': self.mapped('sale_order_id').ids,
'default_company_id': self.company_id.id,
})
action['context'] = context
return action
class ProjectTaskRecurrence(models.Model):
_inherit = 'project.task.recurrence'
@@ -59,16 +59,4 @@
</field>
</record>
<!-- To invoice batch action -->
<record id="project_task_server_action_batch_invoice" model="ir.actions.server">
<field name="name">Create invoice</field>
<field name="model_id" ref="project.model_project_task"/>
<field name="binding_model_id" ref="project.model_project_task"/>
<field name="state">code</field>
<field name="code">
if records:
action = records.action_create_invoice()
</field>
</record>
</odoo>