Inherit mail.activity on res.partner form - odoo-13

I cannot find the view which contain Activities on res.partner form view
I tried to inherit mail.mail_activity_type_view_form but it is not
<record id="mail_activity_view_inherit" model="ir.ui.view">
<field name="name">mail.activity.type.view.form.inherit</field>
<field name="model">mail.activity.type</field>
<field name="inherit_id" ref="mail.mail_activity_type_view_form" />
</record>

The XML-ID is:
mail.res_partner_view_form_inherit_mail
So, mail addon, res_partner_view_form_inherit_mail view.
The view is this one:
<record id="res_partner_view_form_inherit_mail" model="ir.ui.view">
<field name="name">res.partner.view.form.inherit.mail</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//field[#name='email']" position="replace">
<field name="is_blacklisted" invisible="1"/>
<label for="email" class="oe_inline"/>
<div class="o_row o_row_readonly">
<i class="fa fa-ban" style="color: red;" role="img" title="This email is blacklisted for mass mailing" aria-label="Blacklisted" attrs="{'invisible': [('is_blacklisted', '=', False)]}" groups="base.group_user"></i>
<field name="email" widget="email" context="{'gravatar_image': True}" attrs="{'required': [('user_ids','!=', [])]}" />
</div>
</xpath>
<xpath expr="//sheet" position="after">
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="activity_ids" widget="mail_activity"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</xpath>
</field>
</record>

Let me try to help, you're trying to _inherit mail.activity view which is not possible by using xml, because it will not inherit from xml it is written in qweb, so for that you have to extend it like.
<t t-extend="idOfMailAvtivityQweb">
<t t-jquery='i[title="Mark as Todo"]' t-operation="before">
//Here in thread i will add something before title "Mark as Todo"
</t>
</t>

Related

How to change string of Purchase Status(purchase_state) that is in Purchase Request? (ODOO)

So I want to change the string of "Purchase Order" inside Purchase Status(Inside Purchase Request) to something like "PO Created" when the purchase_state is in [purchase] but I don't know how I can do it. I want to create fresh module as well.
Here' s what I tried so far. I've created an XML and inherit the view.
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="purchase_request_form_inherit" model="ir.ui.view">
<field name="name">purchase.request.inherit</field>
<field name="model">purchase.request</field>
<field name="inherit_id" ref="purchase_request.view_purchase_request_form"/>
<field name="arch" type="xml">
<field name="purchase_state" position="attributes">
<attribute name="attrs" string="PO Created" attrs="{'readonly': [('po_line.state','=', 'purchase')]}"/>
</field>
</field>
</record>
</odoo>
I prefer use xpath:
<record id="purchase_request_form_inherit" model="ir.ui.view">
<field name="name">purchase.request.inherit</field>
<field name="model">purchase.request</field>
<field name="inherit_id" ref="purchase_request.view_purchase_request_form"/>
<field name="arch" type="xml">
<field expr="field[#name='purchase_state']" position="attributes">
<!-- To change the String -->
<attribute name="string">PO Created</attribute>
<!-- To change the attrs -->
<attribute name="attrs">{'readonly': [('po_line.state','=', 'purchase')]}</attribute>
</field>
</field>
</record>
I hope this answer could be helpful for you.

Odoo Inherit view can't set invisible attribute

I am odor newer.
I want to use the sale.order field and value to create a custom report by select some specific
field from sale.order.
I have created a custom model to inherit sale.order model.
And create a view to inherit view of sale.order.
Here is my code:
class SaleOrder(models.Model):
_inherit = 'sale.order'
<field name="name">Custom Sale Report</field>
<field name="res_model">sale.order</field>
<field name="view_mode">tree,form</field>
<field name="name">sale.order.inherited</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_tree" />
<field name="mode">primary</field>
<field name="arch" type="xml">
<xpath expr="//field[#name='name']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath> </field> </record>
But I don't know why the invisible attribute is not working.
Please Help. Thanks.
Try this.
<field name="name">sale.order.inherited</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_tree" />
<field name="arch" type="xml">
<xpath expr="//field[#name='name']" position="replace">
<field name="name" optional="hide"/>
</xpath>
</field>
</record>

add div tag in invoice configuration in odoo 12

can anyone please help me regarding invoice configuration in odoo 12.
i am trying to add div tag inside invoice configuration page but got no success.
<record id="res_config_inherit_view_form" model="ir.ui.view">
<field name="name">res.config.form.inherit</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[hasclass('app_settings_block')]" position="inside">
<h2>Notification</h2>
<div></div>
</xpath>
</field>
</record>
i have inherited transient model of res.config.settings in my py file.
i just changed reference from base.res_config_settings_view_form to account.res_config_settings_view_form and
in xpath i added data-key which is sat in the div tag of class named app_settings_block in account.res_config_settings_view_form xml,
in account.invoice it adds all the divs of invoice configuration.
<record id="res_config_inherit_view_form" model="ir.ui.view">
<field name="name">res.config.form.inherit</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="account.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[#data-key='account']" position="inside">
<h2>Notification</h2>
<div class="row mt16 o_settings_container" id="notification">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="unpaid_notification"/>
</div>
<div class="o_setting_right_pane">
<label for="unpaid_notification" string="Unpaid invoice reminder"/>
<div class="text-muted">
Auto send unpaid invoice emails to the partners
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>

how to fix the problem that a menu which is added to an existing menu doesn't be shown

i have develop a custom module which add a new menu in the attendance module to create attendance modification request for both groups "attendance/manual attendance" and "attendance/manager" the problem is my menu is added only for the admin user . If i connect with a user that has the access right manager or manual attendance for the attendance module it will be not shown. Any idea for help ?
Here is my code
hr_attendance_modification_request_view.xml
<record model="ir.ui.view" id="view_attendance_modification_request_form">
<field name="name">attendance.modification.request.form</field>
<field name="model">attendance.modification.request</field>
<field name="arch" type="xml">
<form string="Attendance modification Request">
<header>
<field name="state" statusbar_visible="draft,waiting,approved,cancel" widget="statusbar" />
<button name="submit_modification" string="Submit for manager" type="object" class="btn-primary"
attrs="{'invisible': [('state','not in','draft')]}"/>
<button name="modification_approval" type="object" string="Approve" class="oe_highlight"
groups="hr_attendance.group_hr_attendance_manager"
attrs="{'invisible': [('state','not in','waiting')]}"/>
<button name="modification_rejection" type="object" string="Cancel" class="oe_highlight"
groups="hr_attendance.group_hr_attendance_manager"
attrs="{'invisible': [('state','not in','waiting')]}"/>
</header>
<sheet>
<h2>
<group>
<field name="employee"/>
</group>
</h2>
<group string="Morning" col="4" colspan="4">
<field name="time_check_in_1"/>
<field name="time_check_out_1"/>
</group>
<group string="Afternoon" col="4" colspan="4">
<field name="time_check_in_2"/>
<field name="time_check_out_2"/>
</group>
<label for="note"/>
<field name="note"/>
</sheet>
<field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
<field name="activity_ids" widget="mail_activity"/>
<field name="message_ids" widget="mail_thread"/>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="attendance_modification_request_form_action">
<field name="name">Attendance modification Request</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">attendance.modification.request</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[]</field>
<field name="context">{"search_default_requested_by":uid}</field>
<!-- <field name="search_view_id" ref="view_attendance_request_search"/>-->
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to start a new attendance modification request process.
</p>
</field>
</record>
<menuitem action="attendance_modification_request_form_action" id="menu_attendance_modification_request"
name="Attendance modification request" parent="hr_attendance.menu_hr_attendance_manage_attendances"
sequence="14" groups="hr_attendance.group_hr_attendance"/>
<record model="ir.actions.act_window" id="action_view_attendance_request_approval">
<field name="name">Attendance modification request to approve</field>
<field name="res_model">attendance.modification.request</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','!=','approved'),('state','!=','cancel')]</field>
<field name="help" type="html">
<p class="oe_view_no_content_create">Create new Record
</p>
</field>
</record>
<menuitem action="action_view_attendance_request_approval" id="menu_attendance_modification_request_to_approve"
name="Attendance modification request to Approve"
parent="hr_attendance.menu_hr_attendance_manage_attendances"
sequence="15" groups="hr_attendance.group_hr_attendance_manager"/>
i should add ir.model.access.csv file
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_attendance_modification_request,access_attendance_modification_request,model_attendance_modification_request,hr_attendance.group_hr_attendance_manager,1,1,1,1 access_attendance_modification_request,access_attendance_modification_request,model_attendance_modification_request,hr_attendance.group_hr_attendance,1,1,1,1

Manage webservice from odoo

I am new to Odoo 11, I have created a module called 'coupon', for this module I have created a security group and a default user that is added to this group:
<record id="default_coupon_user" model="res.users">
<field name="login">couponuser</field>
<field name="password">couponuser</field>
<field name="password_crypt">couponuser</field>
<field name="name">Default User Coupon</field>
<field name="display_name">Default Coupon User</field>
<field name="customer">False</field>
</record>
<record id="coupon_managers_group" model="res.groups" >
<field name="name">Coupon Managers Group</field>
<field name="comment">Coupon Managers Group that will be used in the Coupon microservice.</field>
<field name="category_id" ref="base.module_category_coupon"/>
<field name="users" eval="[(4, ref('coupon.default_coupon_user'))]"/>
</record>
My module depends on website because I need to create a website, for that site I created an index page:
<!-- === Coupon Page === -->
<template id="index_template">
<t t-call="website.layout">
<div id="wrap">
<div class="container">
<h1>Coupons</h1>
<a href="/payum_coupon/create" class="btn btn-primary btn-lg">
Add
</a>
<p>paginas:
<t t-esc="coupons['pg']"/>
</p>
<p>total:
<t t-esc="coupons['total']"/>
</p>
<ul class="clientes">
<t t-foreach="coupons['items']" t-as="i">
<li>
<a t-attf-href="/payum_coupon/{{i['email']}}">
<t t-esc="i['firstName']"/>
<t t-esc="i['lastName']"/>
-
<t t-esc="i['email']"/>
</a>
</li>
</t>
</ul>
</div>
</div>
</t>
</template>
<record id="coupon_page" model="website.page">
<field name="name">Index Coupon page</field>
<field name="website_published">True</field>
<field name="url">/coupon</field>
<field name="view_id" ref="index_template"/>
<field name="groups">coupon.coupon_managers_group</field>
</record>
and website.menu with the following code:
<record id="coupon_page_link" model="website.menu">
<field name="name">Coupon</field>
<field name="page_id" ref="coupon_page"/>
<field name="parent_id" ref="website.main_menu"/>
</record>
the python code in the controller that will be executed by said menu is this:
#http.route('/coupon', auth='user', website=True)
def index(self, **kw):
#<<my code here>>
I need several things:
when the 'index' page is displayed if the user in session is not in the 'coupon.coupon_managers_group' group then the menu is not shown
And that when the controller method '/coupon' is executed it is verified that the user in session is in the group 'coupon.coupon_managers_group'
This site has a particularity and that my module does not have models, since it is to manage the data of an api rest application, that is, in odoo I have to create the views of list, create, etc., but the data is written and they are read from a remote web service.
I have searched many sites on the internet but I have not found anything, as they always refer to local cases in odoo.
To hide the website menu based on the user group you could do something like this:
from odoo import api, models
class Menu(models.Model):
_inherit = "website.menu"
#api.one
def _compute_visible(self):
if self.clean_url() == '/coupon' and not self.env.user.has_group('coupon.coupon_managers_group'):
return False
return super(Menu, self)._compute_visible()
In the controller of the route /coupon you could check the user group like:
request.env.user.has_group('coupon.coupon_managers_group')

Resources