I want to add a cron job that runs at a specific time.
I have added the cron in xml but it has interval_number and interval_type. How to make it run at a specific time of day?
<record id="ir_cron_module_get_active_sr" model="ir.cron">
<field name="name">Get Active Srs</field>
<field eval="True" name="get_active_srs" />
<!--<field name="user_id" ref="base.user_root" />-->
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall" />
<field eval="'hr.attendance'" name="model" />
<field eval="'get_active_srs'" name="function" />
<field eval="'(None,)'" name="args" />
<field name="priority">1000</field>
</record>
try
<record id="ir_cron_module_get_active_sr" model="ir.cron">
<field name="name">Get Active Srs</field>
<field eval="True" name="get_active_srs" />
<!--<field name="user_id" ref="base.user_root" />-->
<field name="interval_number">1</field>
<field name="nextcall" eval="(DateTime.now() + timedelta(days=1)).strftime('%Y-%m-%d 12:00:00')" />
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall" />
<field eval="'hr.attendance'" name="model" />
<field eval="'get_active_srs'" name="function" />
<field eval="'(None,)'" name="args" />
<field name="priority">1000</field>
</record>
Related
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.
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>
I'm trying to add a custom field in product_templte_form_vieew by doing this :
<!-- product template -->
<record id="mymoduleproduct_view_form" model="ir.ui.view">
<field name="name">mymodule.product</field>
<field name="model">mymodule.product</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//notebook/page[#name='general_information']/group[2]" position="attributes">
<field name="prixass"/>
<field name="taxes_id" position="attributes">
<attribute name="invisible">1</attribute>
</field>
</xpath>
</field>
</record>
No error in excution but it seems to not work. Need help to detect or correct what is wrong.
I have already define ‘prixass’ fields like this :
class MyModuleProduct(models.Model):
_name = "mymodule.product"
_description = "table des articles"
_inherit = "product.template"
prixass = fields.Float(string='Prix Assurance')
taxes_id = fields.Many2many('account.tax', 'product_hospi_taxes', 'prod_hospi_id', 'tax_id', string='Customer Taxes')
supplier_taxes_id = fields.Many2many('account.tax', 'product_hospi_supplier_taxes', 'prod_hospi_id', 'tax_id', string='Vendor Taxes')
route_ids = fields.Many2many('stock.location.route', 'stock_route_product_hospi', 'product_hospi_id', 'route_id', string='Routes',)
Also i’ld like to remove the fields taxes_id from the view, how do i do ?
.
the resume of the question in image here
Thanks .
Try this.
class MyModuleProduct(models.Model):
_inherit = "product.template"
prixass = fields.Float(string='Prix Assurance')
taxes_id = fields.Many2many('account.tax', 'product_hospi_taxes', 'prod_hospi_id', 'tax_id', string='Customer Taxes')
supplier_taxes_id = fields.Many2many('account.tax', 'product_hospi_supplier_taxes', 'prod_hospi_id', 'tax_id', string='Vendor Taxes')
route_ids = fields.Many2many('stock.location.route', 'stock_route_product_hospi', 'product_hospi_id', 'route_id', string='Routes',)
<record id="product_inherit_view" model="ir.ui.view">
<field name="name">product.template</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//notebook/page[#name='general_information']/field[#name='default_code']" position="after">
<field name="prixass"/>
</xpath>
<field name="taxes_id" position="replace">
<field name="taxes_id" invisible="1"/>
</field>
</field>
</record>
but this work for me now
//model
class MyModuleProduct(models.Model):
_inherit = "product.template"
prixass = fields.Float(string='Prix Assurance')
taxes_id = fields.Many2many('account.tax', 'product_hospi_taxes', 'prod_hospi_id', 'tax_id', string='Customer Taxes')
supplier_taxes_id = fields.Many2many('account.tax', 'product_hospi_supplier_taxes', 'prod_hospi_id', 'tax_id', string='Vendor Taxes')
route_ids = fields.Many2many('stock.location.route', 'stock_route_product_hospi', 'product_hospi_id', 'route_id', string='Routes',)
//views
<record id="product_inherit_view" model="ir.ui.view">
<field name="name">product.template</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//notebook/page[#name='general_information']/group[1]" position="after">
<group>
<field name="prixass"/>
</group>
</xpath>
<field name="taxes_id" position="replace">
<field name="taxes_id" invisible="1"/>
</field>
</record>
thanks.
I have the folling XML (as string)
xml = '''
<?xml version="1.0" encoding="utf-8"?>
<Response total="00:00:00.2130175">
<Result>
<Channel name="test">
<TotalCount ignoringpaging="2">2</TotalCount>
<Products>
<Product id="8050" ecommerceproduct="Productname">
<Fields>
<Field name="pid">8050</Field>
<Field name="ProductName">Productname</Field>
<Field name="ProductCategorie" culture="nl-NL">Category</Field>
<Field name="Titel" culture="nl-NL">Product Titel</Field>
<Field name="ProductHoogte">74</Field>
<Field name="ProductVerstelbaarheid">Vast</Field>
<Field name="ProductDikte">25</Field>
<Field name="ProductMateriaal">Gemelamineerd spaanplaat</Field>
<Field name="ProductLijn">0</Field>
<Field name="prodId">63258518</Field>
</Fields>
<Variants>
<Variant id="8060" ecommerceproduct="Productname">
<Fields>
<Field name="ProductName">Productname / Black</Field>
<Field name="PID">8060</Field>
<Field name="Zichtbaar">Y</Field>
<Field name="articleCode">123456</Field>
<Field name="priceExcl">469</Field>
<Field name="ProductBreedte">180</Field>
<Field name="ProductDiepte">80</Field>
<Field name="ProductHoogte">74</Field>
<Field name="varId">121655579</Field>
<Field name="visible">Y</Field>
</Fields>
</Variant>
</Variants>
</Product>
<Product id="8051" ecommerceproduct="Productname 2">
<Fields>
<Field name="pid">8051</Field>
<Field name="ProductName">Productname 2</Field>
<Field name="ProductCategorie" culture="nl-NL">Category</Field>
<Field name="Titel" culture="nl-NL">Product Titel 2</Field>
<Field name="ProductHoogte">74</Field>
<Field name="ProductVerstelbaarheid">Vast</Field>
<Field name="ProductDikte">25</Field>
<Field name="ProductMateriaal">Gemelamineerd spaanplaat</Field>
<Field name="ProductLijn">0</Field>
<Field name="prodId">63258520</Field>
</Fields>
<Variants>
<Variant id="8061" ecommerceproduct="Productname 2">
<Fields>
<Field name="ProductName">Productname 2 / White</Field>
<Field name="PID">8061</Field>
<Field name="Zichtbaar">Y</Field>
<Field name="articleCode">234567</Field>
<Field name="priceExcl">499</Field>
<Field name="ProductBreedte">180</Field>
<Field name="ProductDiepte">80</Field>
<Field name="ProductHoogte">74</Field>
<Field name="varId">216555798</Field>
<Field name="visible">N</Field>
</Fields>
</Variant>
</Variants>
</Product>
</Products>
</Channel>
</Result>
</Response>'''
with xml.etree I can iterate over the Products, but how can I get all the values of the fields and variants fields.
root = ET.fromstring(xml)
for p in root.iter('Product'):
print(p.attrib)
the output I get is:
{'id': '8050', 'ecommerceproduct': 'Productname'}
{'id': '8060', 'ecommerceproduct': 'Productname 2'}
So this seems to work, but whatever I try to get the values from the fields, I get no response.
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