I've setup a ir.server.action that reacts to when the model is saved and is in a manual state. However repeated saves will repeatedly trigger the action, so I have to lock on the database. Currently I have this:
<record id="filter_order_confirm" model="ir.filters">
<field name="name">By Confirmed Orders</field>
<field name="model_id">sale.order</field>
<field name="domain">[('state','=','manual')]</field>
</record>
<record id="action_schedule_emails" model="ir.actions.server">
<field name="state">code</field>
<field name="model_id" ref="sale.model_sale_order"/>
<field name="code">object.schedule_emails()</field>
<field name="type">ir.actions.server</field>
<field name="condition">True</field>
<field name="name">Schedule Emails</field>
</record>
<record id="rule_trigger_email_scheduling" model="base.action.rule">
<field name="name">Trigger email scheduling when Order is set to confirm.</field>
<field name="model_id" ref="sale.model_sale_order" />
<field name="kind">on_create_or_write</field>
<field name="filter_id" ref="filter_order_confirm" />
<field name="server_action_ids" eval="[(6,0,[ref('action_schedule_emails')])]" />
</record>
How can I react to the order being confirmed in the workflow instead?
You can modify the workflow activity to trigger any server action when is executed.
In your case you need to modify the act_router activity in sale.wkf_sale this can be done from your addon like this.
<record id="sale.act_router" model="workflow.activity">
<field name="action_id" ref="action_schedule_emails"/>
</record>
With this modification the code on your server action is triggered when the order is confirmed.
Related
I used ir.actions.server model for add an option in action menu item.
Main purpose for using this is to run python code from here.Here i don't want to return a tree or form view here , so i used this method.
I need to add an option only in vendor bills form, but the option is set both invoice and supplier form.
<record id="account_invoice_accrual_entries_vendor_bill_non_po_action" model="ir.actions.server">
<field name="name">Accrual Entries</field>
<field name="model_id" ref="model_account_invoice"/>
<field name="domain">[('type','in',('in_invoice'))]</field>
<field name="state">code</field>
<field name="code">
if records:
records.action_accrual_entries_vendor_bill()
</field>
</record>
<record id="account_invoice_accrual_entries_vendor_bill_non_po" model="ir.values">
<field name="model_id" ref="account.model_account_invoice"/>
<field name="name">Accrual Entries</field>
<field name="key2">client_action_multi</field>
<field name="key">action</field>
<field name="model">account.invoice</field>
<field name="value" eval="'ir.actions.server,' + str(ref('account_invoice_accrual_entries_vendor_bill_non_po_action'))" />
</record>
This is the code i try to add domain only for vendor bills. But the option visible in both vendor bills and customer invoice.
anyone knows what is the mistake in my code .??
I want to hide the edit and create button on the form view for a specific user I use this code but the button not showing at all
i just want to hide buttons just for only group
<record model="ir.ui.view" id="edit_button_message_">
<field name="name">edit.button.message.1</field>
<field name="model">person.message</field>
<field name="inherit_id" ref="view_parent_message_form"/>
<field name="groups_id" eval="[(6,0,[ref('person_access')])]"/>
<field name="arch" type="xml">
<xpath expr="/form[#string='form_view_string']" position="attributes">
<attribute name="create">false</attribute>
<attribute name="edit">false</attribute>
</xpath>
</field>
</record>
and i use this
<form string="form_view_string" edit="false" create="false" >
nothing happened , I use odoo v8
You better create a security access for that group to allow just read to that model, preventing the create, write and unlink actions and those buttons should disappear.
You could create it in xml as it will be only one, like:
<record id="person_message_access" model="ir.model.access">
<field name="name">edit.button.message.access</field>
<field name="model_id" ref="person.message"/>
<field name="group_id" ref="person_access"/>
<field name="perm_read" eval="1"/>
<field name="perm_create" eval="0"/>
<field name="perm_write" eval="0"/>
<field name="perm_unlink" eval="0"/>
</record>
or you could set it into a field ir.model.access.csv with content like:
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
person_message_access,edit.button.message.access,model_person_message,person_access,1,0,0,0
I have made some groups A,B,C,D through GUI in Odoo v10. These groups are shown as check-boxes on the user page.
I want that instead of these check-boxes a dropdown must be shown so that user can be assigned to only a single group i.e. a user can only be in one of the A,B,C,D groups.
How can i do this??
I've found something that will clear how drop-downs are made and how check boxes are made. This is through code not from GUI as i am still finding a solution for it.
So, drop-downs are made when each group in a category inherits some other group in same category in hierarchical manner.
So, when i wrote the following code, check-boxes were made.
<record id='group_category' model='ir.module.category'>
<field name='name'>Category name</field>
</record>
<record id="group_a" model="res.groups">
<field name="name">A</field>
<field name="category_id" ref="group_category"/>
</record>
<record id="group_b" model="res.groups">
<field name="name">B</field>
<field name="category_id" ref="group_category"/>
</record>
<record id="group_c" model="res.groups">
<field name="name">C</field>
<field name="category_id" ref="group_category"/>
</record>
But when i wrote the following code in which one group inherits the other in a hierarchical way, drop-down was made
<record id='group_category' model='ir.module.category'>
<field name='name'>Category name</field>
</record>
<record id="group_a" model="res.groups">
<field name="name">A</field>
<field name="category_id" ref="group_category"/>
</record>
<record id="group_b" model="res.groups">
<field name="name">B</field>
<field name="category_id" ref="group_category"/>
<field name="implied_ids" eval="[(4, ref('module_name.group_a'))]"/>
</record>
<record id="group_c" model="res.groups">
<field name="name">C</field>
<field name="category_id" ref="group_category"/>
<field name="implied_ids" eval="[(4, ref('module_name.group_b'))]"/>
</record>
so, this was the case when i did it. Still finding a way to do it through GUI.
First Create this below record through xml.
<record model="ir.module.category" id="abcd_category">
<field name="name">ABCD</field>
</record>
Then Create your groups with category_id.
<record id="group_a" model="res.groups">
<field name="name">A</field>
<field name="category_id" ref="abcd_category"/>
</record>
<record id="group_b" model="res.groups">
<field name="name">B</field>
<field name="category_id" ref="abcd_category"/>
</record>
......
......
Thats it.
Updates :
Add category in manifest.py
....
....
'category':'ABCD',
....
....
and select it from view into the Application in group formview.
You can override the view and specify a widget. You could try:
<field name="field_name" widget="selection"/>
or
<field name="field_name" widget="many2one"/>
I hope this help you!
I'm new to Odoo and I'm looking for a way to add/edit columns in the overview of customer invoices.
Does anyone know which files to edit? Or how this "overview screen" is called so I can look it up better?
Link to screenshot of overview screen: http://oi58.tinypic.com/2prtyk0.jpg
Thanks in advance!
The VIEW of this "TREE" is defined in
addons/account/views/account_invoice_view.xml
Which has the code like this:
<record id="invoice_tree" model="ir.ui.view">
<field name="name">account.invoice.tree</field>
<field name="model">account.invoice</field>
<field name="arch" type="xml">
<tree decoration-info="state == 'draft'" decoration-muted="state == 'cancel'" string="Invoice">
<field name="partner_id" groups="base.group_user" string="Customer"/>
<field name="date_invoice"/>
<field name="number"/>
<field name="commercial_partner_id" invisible="1"/>
<field name="reference" invisible="1"/>
<field name="name" invisible="1"/>
<field name="journal_id" invisible="1"/>
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
<field name="user_id"/>
<field name="date_due"/>
<field name="origin"/>
<field name="amount_total_signed" sum="Total Amount"/>
<field name="residual_signed" sum="Residual Amount"/>
<field name="currency_id" invisible="1"/>
<field name="company_currency_id" invisible="1"/>
<field name="state"/>
<field name="type" invisible="context.get('type',True)"/>
</tree>
</field>
</record>
I recommend you use developer mode to know the name of the view what you want change/edit/inherit/..etc,
Go to Administrator => About Odoo => Activate Developer Mode then return to the view and you will see near to the name of the current view a Drop-down list with name Debug View#xx click there and choice Edit TreeView/FormView/...etc after that you are going to see the definition of the current view, in this way you will know what view you need to inherit/edit/..etc
I hope this will help you!
In openerp there's a standard module named account_followup_print, in here there's a method called do_process which sends out all the payment followup emails.
I want it to automatically do this every day without having to click the button. So I have made the following:
<openerp>
<data>
<record forcecreate="True" id="ir_cron_project_task" model="ir.cron">
<field name="name">Run Payment Follow-up scheduler</field>
<field eval="True" name="active"/>
<field name="user_id" ref="base.user_root"/>
<field name="interval_number">1</field>
<field name="interval_type">minutes</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall"/>
<field eval="'account_followup.print'" name="model"/>
<field eval="'do_process'" name="function"/>
</record>
</data>
Yet this does not work, what am I doing wrong here? Thanks in advance!
Try following,
<record id = "ir_cron_project_task" model = "ir.cron">
<field name="name">Run Payment Follow-up scheduler</field>
<field eval="True" name="active"/>
<field name="user_id" ref="base.user_root"/>
<field name="interval_number">1</field>
<field name="interval_type">minutes</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall"/>
<field eval="'account_followup.print'" name="model"/>
<field eval="'do_process'" name="function"/>
<field eval="'()'" name="args"/>
</record>