[MERGE] trunk
bzr revid: openerp-sle@openerp-sle.home-20140213121633-d1qnw9hsgz2e392d
This commit is contained in:
@@ -729,8 +729,7 @@ class account_journal(osv.osv):
|
||||
'currency': fields.many2one('res.currency', 'Currency', help='The currency used to enter statement'),
|
||||
'entry_posted': fields.boolean('Autopost Created Moves', help='Check this box to automatically post entries of this journal. Note that legally, some entries may be automatically posted when the source document is validated (Invoices), whatever the status of this field.'),
|
||||
'company_id': fields.many2one('res.company', 'Company', required=True, select=1, help="Company related to this journal"),
|
||||
'allow_date':fields.boolean('Check Date in Period', help= 'If set to True then do not accept the entry if the entry date is not into the period dates'),
|
||||
|
||||
'allow_date':fields.boolean('Check Date in Period', help= 'If checked, the entry won\'t be created if the entry date is not included into the selected period'),
|
||||
'profit_account_id' : fields.many2one('account.account', 'Profit Account'),
|
||||
'loss_account_id' : fields.many2one('account.account', 'Loss Account'),
|
||||
'internal_account_id' : fields.many2one('account.account', 'Internal Transfers Account', select=1),
|
||||
|
||||
@@ -495,6 +495,7 @@ class account_bank_statement(osv.osv):
|
||||
ctx = (context or {}).copy()
|
||||
ctx['journal_id'] = self.browse(cr, uid, ids[0], context=context).journal_id.id
|
||||
return {
|
||||
'name': _('Journal Items'),
|
||||
'view_type':'form',
|
||||
'view_mode':'tree',
|
||||
'res_model':'account.move.line',
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
<field name="journal_id" invisible="1"/>
|
||||
<field name="period_id" invisible="1" groups="account.group_account_user"/>
|
||||
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
|
||||
<field name="user_id"/>
|
||||
<field name="user_id" string="Responsible"/>
|
||||
<field name="date_due"/>
|
||||
<field name="origin"/>
|
||||
<field name="currency_id" groups="base.group_multi_currency"/>
|
||||
@@ -251,7 +251,7 @@
|
||||
<group>
|
||||
<group>
|
||||
<field domain="[('partner_id', '=', partner_id)]" name="partner_bank_id" on_change="onchange_partner_bank(partner_bank_id)"/>
|
||||
<field name="user_id" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'account.group_account_invoice']}"/>
|
||||
<field name="user_id" string="Responsible" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'account.group_account_invoice']}"/>
|
||||
<field name="name" invisible="1"/>
|
||||
<field name="payment_term" widget="selection"/>
|
||||
</group>
|
||||
|
||||
@@ -1270,12 +1270,11 @@
|
||||
<field name="model">account.move</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Account Entry" version="7.0">
|
||||
<header>
|
||||
<button name="button_validate" states="draft" string="Post" type="object" class="oe_highlight" groups="account.group_account_invoice"/>
|
||||
<button name="button_cancel" states="posted" string="Cancel Entry" type="object" groups="account.group_account_invoice"/>
|
||||
<field name="state" widget="statusbar"/>
|
||||
</header>
|
||||
<sheet string="Journal Entries" >
|
||||
<header>
|
||||
<button name="button_validate" states="draft" string="Post" type="object" class="oe_highlight" groups="account.group_account_invoice"/>
|
||||
<button name="button_cancel" states="posted" string="Cancel Entry" type="object" groups="account.group_account_invoice"/>
|
||||
<field name="state" widget="statusbar"/>
|
||||
</header>
|
||||
<label for="name" class="oe_edit_only" attrs="{'invisible':[('name','=','/')]}"/>
|
||||
<h1>
|
||||
<field name="name" readonly="True" attrs="{'invisible':[('name','=','/')]}"/>
|
||||
@@ -1384,7 +1383,6 @@
|
||||
<field name="narration" colspan="4" placeholder="Add an internal note..." nolabel="1" height="50"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
@@ -2263,7 +2261,7 @@
|
||||
<group>
|
||||
<group>
|
||||
<field name="journal_id" on_change="onchange_journal_id(journal_id)" widget="selection" domain="[('type', '=', 'cash')]" />
|
||||
<field name="user_id" readonly="1" string="Responsible"/>
|
||||
<field name="user_id" attrs="{'readonly':[('state','!=','draft')]}" string="Responsible"/>
|
||||
<field name='company_id' widget="selection" groups="base.group_multi_company" />
|
||||
</group>
|
||||
<group>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<label for="fiscalyear"/>
|
||||
<div>
|
||||
<field name="fiscalyear" on_change="onchange_fiscalyear(fiscalyear)" class="oe_inline"/>
|
||||
<label align="0.7" string="(If you do not select Fiscal year it will take all open fiscal years)" class="oe_inline"/>
|
||||
<label align="0.7" string="(If you do not select a specific fiscal year, all open fiscal years will be selected.)" class="oe_inline"/>
|
||||
</div>
|
||||
<field name="target_move"/>
|
||||
<label for="period_from" string="Periods"/>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<label for="period_id"/>
|
||||
<div>
|
||||
<field name="period_id" class="oe_inline"/>
|
||||
<label string="(If you do not select period it will take all open periods)" class="oe_inline"/>
|
||||
<label string="(If you do not select a specific period, all open periods will be selected)" class="oe_inline"/>
|
||||
</div>
|
||||
<field name="target_move"/>
|
||||
</group>
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
<field name="model">account.move</field>
|
||||
<field name="inherit_id" ref="account.view_move_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="/form/sheet/notebook/page/field[@name='line_id']/tree/field[@name='analytic_account_id']" position="replace">
|
||||
<xpath expr="/form/notebook/page/field[@name='line_id']/tree/field[@name='analytic_account_id']" position="replace">
|
||||
<field name="analytics_id" context="{'journal_id':parent.journal_id}" groups="analytic.group_analytic_accounting"/>
|
||||
</xpath>
|
||||
<xpath expr="/form/sheet/notebook/page/field[@name='line_id']/form/notebook/page/group/group/field[@name='analytic_account_id']" position="replace">
|
||||
<xpath expr="/form/notebook/page/field[@name='line_id']/form/notebook/page/group/group/field[@name='analytic_account_id']" position="replace">
|
||||
<field name="analytics_id" context="{'journal_id':parent.journal_id}" groups="analytic.group_analytic_accounting"/>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
@@ -352,6 +352,7 @@ class account_asset_asset(osv.osv):
|
||||
context = {}
|
||||
context.update({'search_default_asset_id': ids, 'default_asset_id': ids})
|
||||
return {
|
||||
'name': _('Journal Items'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.move.line',
|
||||
|
||||
@@ -26,7 +26,7 @@ class account_journal(osv.osv):
|
||||
|
||||
_columns = {
|
||||
'allow_check_writing': fields.boolean('Allow Check writing', help='Check this if the journal is to be used for writing checks.'),
|
||||
'use_preprint_check': fields.boolean('Use Preprinted Check'),
|
||||
'use_preprint_check': fields.boolean('Use Preprinted Check', help='Check if you use a preformated sheet for check'),
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Populate Statement:" version="7.0">
|
||||
<group>
|
||||
<field name="lines"/>
|
||||
<field name="lines" nolabel="1"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="populate_statement" string="ADD" type="object" class="oe_highlight"/>
|
||||
<button name="populate_statement" string="Ok" type="object" class="oe_highlight"/>
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel"/>
|
||||
</footer>
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
<field name="tax_amount" nolabel="1"/>
|
||||
<div class="oe_subtotal_footer_separator">
|
||||
<label for="amount"/>
|
||||
<button type="object" icon="terp-stock_format-scientific" name="compute_tax" class="oe_link oe_edit_only" string="(Update)" attrs="{'invisible': [('state','!=','draft')]}"/>
|
||||
<button type="object" name="compute_tax" class="oe_link oe_edit_only" string="(Update)" attrs="{'invisible': [('state','!=','draft')]}"/>
|
||||
</div>
|
||||
<field name="amount" class="oe_subtotal_footer_separator" nolabel="1"/>
|
||||
</group>
|
||||
|
||||
@@ -253,7 +253,7 @@ class account_analytic_account(osv.osv):
|
||||
def check_recursion(self, cr, uid, ids, context=None, parent=None):
|
||||
return super(account_analytic_account, self)._check_recursion(cr, uid, ids, context=context, parent=parent)
|
||||
|
||||
_order = 'name asc'
|
||||
_order = 'code, name asc'
|
||||
_constraints = [
|
||||
(check_recursion, 'Error! You cannot create recursive analytic accounts.', ['parent_id']),
|
||||
]
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<field name="name">Meeting Types Tree</field>
|
||||
<field name="model">calendar.event.type</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Meeting Types" editable="bottom">
|
||||
<tree string="Meeting Types">
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
||||
@@ -49,9 +49,7 @@
|
||||
}
|
||||
</field>
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
Click to create a new opportunity.
|
||||
</p><p>
|
||||
<p>
|
||||
OpenERP helps you keep track of your sales pipeline to follow
|
||||
up potential sales and better forecast your future revenues.
|
||||
</p><p>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<field name="name">Direct Sales</field>
|
||||
<field name="code">DM</field>
|
||||
<field name="use_leads">True</field>
|
||||
<field name="alias_name">info</field>
|
||||
<field name="alias_name">sales</field>
|
||||
<field name="member_ids" eval="[(4, ref('base.user_root'))]"/>
|
||||
</record>
|
||||
|
||||
@@ -56,6 +56,14 @@
|
||||
<field name="section_id" ref="crm.section_sales_department"/>
|
||||
</record>
|
||||
|
||||
<!--default alias for leads-->
|
||||
<record id="mail_alias_lead_info" model="mail.alias">
|
||||
<field name="alias_name">info</field>
|
||||
<field name="alias_model_id" ref="model_crm_lead"/>
|
||||
<field name="alias_user_id" ref="base.user_root"/>
|
||||
<field name="alias_parent_model_id" ref="model_crm_case_section"/>
|
||||
</record>
|
||||
|
||||
<!-- notify all employees of module installation -->
|
||||
<record model="mail.message" id="module_install_notification">
|
||||
<field name="model">mail.group</field>
|
||||
|
||||
@@ -950,6 +950,14 @@ class crm_lead(format_address, osv.osv):
|
||||
default['stage_id'] = self._get_default_stage_id(cr, uid, local_context)
|
||||
return super(crm_lead, self).copy(cr, uid, id, default, context=context)
|
||||
|
||||
def get_empty_list_help(self, cr, uid, help, context=None):
|
||||
context['empty_list_help_model'] = 'crm.case.section'
|
||||
context['empty_list_help_id'] = context.get('default_section_id', None)
|
||||
context['empty_list_help_document_name'] = _("opportunity")
|
||||
if context.get('default_type') == 'lead':
|
||||
context['empty_list_help_document_name'] = _("lead")
|
||||
return super(crm_lead, self).get_empty_list_help(cr, uid, help, context=context)
|
||||
|
||||
# ----------------------------------------
|
||||
# Mail Gateway
|
||||
# ----------------------------------------
|
||||
|
||||
@@ -44,9 +44,7 @@
|
||||
<field name="view_id" eval="False"/>
|
||||
<field name="search_view_id" ref="crm.view_crm_case_opportunities_filter"/>
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
Click to create a new opportunity.
|
||||
</p><p>
|
||||
<p>
|
||||
OpenERP helps you keep track of your sales pipeline to follow
|
||||
up potential sales and better forecast your future revenues.
|
||||
</p><p>
|
||||
|
||||
@@ -264,14 +264,16 @@ class crm_phonecall(osv.osv):
|
||||
Open meeting's calendar view to schedule a meeting on current phonecall.
|
||||
:return dict: dictionary value for created meeting view
|
||||
"""
|
||||
partner_ids = []
|
||||
phonecall = self.browse(cr, uid, ids[0], context)
|
||||
if phonecall.partner_id and phonecall.partner_id.email:
|
||||
partner_ids.append(phonecall.partner_id.id)
|
||||
res = self.pool.get('ir.actions.act_window').for_xml_id(cr, uid, 'calendar', 'action_calendar_event', context)
|
||||
res['context'] = {
|
||||
'default_phonecall_id': phonecall.id,
|
||||
'default_partner_id': phonecall.partner_id and phonecall.partner_id.id or False,
|
||||
'default_partner_ids': partner_ids,
|
||||
'default_user_id': uid,
|
||||
'default_email_from': phonecall.email_from,
|
||||
'default_state': 'open',
|
||||
'default_name': phonecall.name,
|
||||
}
|
||||
return res
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
<field name="view_mode">tree,calendar</field>
|
||||
<field name="view_id" ref="crm_case_inbound_phone_tree_view"/>
|
||||
<field name="domain">[]</field>
|
||||
<field name="context">{'default_state': 'done'}</field>
|
||||
<field name="context">{}</field>
|
||||
<field name="search_view_id" ref="crm.view_crm_case_phonecalls_filter"/>
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
@@ -106,7 +106,7 @@
|
||||
<field name="view_mode">tree,calendar</field>
|
||||
<field name="view_id" ref="crm_case_phone_tree_view"/>
|
||||
<field name="domain">[('state','!=','done')]</field>
|
||||
<field name="context" eval="'{\'default_state\':\'open\'}'"/>
|
||||
<field name="context">{}</field>
|
||||
<field name="search_view_id" ref="crm.view_crm_case_phonecalls_filter"/>
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp import SUPERUSER_ID
|
||||
from openerp.osv import fields, osv
|
||||
|
||||
|
||||
@@ -66,7 +67,42 @@ class crm_configuration(osv.TransientModel):
|
||||
'group_multi_salesteams': fields.boolean("Organize Sales activities into multiple Sales Teams",
|
||||
implied_group='base.group_multi_salesteams',
|
||||
help="""Allows you to use Sales Teams to manage your leads and opportunities."""),
|
||||
'alias_prefix': fields.char('Default Alias Name for Leads'),
|
||||
'alias_domain' : fields.char('Alias Domain'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'alias_domain': lambda self, cr, uid, context: self.pool['mail.alias']._get_alias_domain(cr, SUPERUSER_ID, [1], None, None)[1],
|
||||
}
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
def _find_default_lead_alias_id(self, cr, uid, context=None):
|
||||
alias_id = self.pool['ir.model.data'].xmlid_to_res_id(cr, uid, 'crm.mail_alias_lead_info')
|
||||
if not alias_id:
|
||||
alias_ids = self.pool['mail.alias'].search(
|
||||
cr, uid, [
|
||||
('alias_model_id.model', '=', 'crm.lead'),
|
||||
('alias_force_thread_id', '=', False),
|
||||
('alias_parent_model_id.model', '=', 'crm.case.section'),
|
||||
('alias_parent_thread_id', '=', False),
|
||||
('alias_defaults', '=', '{}')
|
||||
], context=context)
|
||||
alias_id = alias_ids and alias_ids[0] or False
|
||||
return alias_id
|
||||
|
||||
def get_default_alias_prefix(self, cr, uid, ids, context=None):
|
||||
alias_name = False
|
||||
alias_id = self._find_default_lead_alias_id(cr, uid, context=context)
|
||||
if alias_id:
|
||||
alias_name = self.pool['mail.alias'].browse(cr, uid, alias_id, context=context).alias_name
|
||||
return {'alias_prefix': alias_name}
|
||||
|
||||
def set_default_alias_prefix(self, cr, uid, ids, context=None):
|
||||
mail_alias = self.pool['mail.alias']
|
||||
for record in self.browse(cr, uid, ids, context=context):
|
||||
alias_id = self._find_default_lead_alias_id(cr, uid, context=context)
|
||||
if not alias_id:
|
||||
create_ctx = dict(context, alias_model_name='crm.lead', alias_parent_model_name='crm.case.section')
|
||||
alias_id = self.pool['mail.alias'].create(cr, uid, {'alias_name': record.alias_prefix}, context=create_ctx)
|
||||
else:
|
||||
mail_alias.write(cr, uid, alias_id, {'alias_name': record.alias_prefix}, context=context)
|
||||
return True
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<field name="model">sale.config.settings</field>
|
||||
<field name="inherit_id" ref="base_setup.view_sale_config_settings"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<div name="config_sale" position="before">
|
||||
<separator string="After-Sale Services"/>
|
||||
<group>
|
||||
@@ -26,11 +27,31 @@
|
||||
<group>
|
||||
<label for="id" string="Manage Sales Teams"/>
|
||||
<div>
|
||||
<field name="group_multi_salesteams" class="oe_inline"/>
|
||||
<label for="group_multi_salesteams"/>
|
||||
<div>
|
||||
<field name="group_multi_salesteams" class="oe_inline"/>
|
||||
<label for="group_multi_salesteams"/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</group>
|
||||
</div>
|
||||
<xpath expr="//group[@name='On Mail Client']" position="before">
|
||||
<group name="default_alias">
|
||||
<label for="id" string="Leads Email Alias"/>
|
||||
<div attrs="{'invisible': [('alias_domain', '=', False)]}">
|
||||
<div>
|
||||
<field name="alias_prefix" class="oe_inline" attrs="{'required': [('alias_domain', '!=', False)]}"/>
|
||||
@
|
||||
<field name="alias_domain" class="oe_inline" readonly="1"/>
|
||||
</div>
|
||||
<p>
|
||||
All emails sent to this address and processed by the mailgateway
|
||||
will create a new lead.
|
||||
</p>
|
||||
</div>
|
||||
</group>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -50,9 +50,9 @@ class hr_applicant_settings(osv.TransientModel):
|
||||
alias_ids = self.pool['mail.alias'].search(
|
||||
cr, uid, [
|
||||
('alias_model_id.model', '=', 'hr.applicant'),
|
||||
('alias_force_thread_id', '=', 0),
|
||||
('alias_force_thread_id', '=', False),
|
||||
('alias_parent_model_id.model', '=', 'hr.job'),
|
||||
('alias_parent_thread_id', '=', 0),
|
||||
('alias_parent_thread_id', '=', False),
|
||||
('alias_defaults', '=', '{}')
|
||||
], context=context)
|
||||
alias_id = alias_ids and alias_ids[0] or False
|
||||
|
||||
@@ -129,10 +129,6 @@ class Scanner(Thread):
|
||||
self.set_status('error',str(e))
|
||||
return None
|
||||
|
||||
@http.route('/hw_proxy/Vis_scanner_connected', type='json', auth='none', cors='*')
|
||||
def is_scanner_connected(self):
|
||||
return self.get_device() != None
|
||||
|
||||
def get_barcode(self):
|
||||
""" Returns a scanned barcode. Will wait at most 5 seconds to get a barcode, and will
|
||||
return barcode scanned in the past if they are not older than 5 seconds and have not
|
||||
|
||||
@@ -13,7 +13,7 @@ msgstr ""
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2014-02-12 05:29+0000\n"
|
||||
"X-Launchpad-Export-Date: 2014-02-13 05:48+0000\n"
|
||||
"X-Generator: Launchpad (build 16916)\n"
|
||||
|
||||
#. module: mrp
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<!-- Resource: project.project -->
|
||||
<record id="all_projects_account" model="account.analytic.account">
|
||||
<field name="name">Projects</field>
|
||||
<field name="code">3</field>
|
||||
<field name="code">PP001</field>
|
||||
<field name="type">view</field>
|
||||
</record>
|
||||
<function id="parent_project_default_set" model="ir.values" name="set" eval="('default',False,'parent_id', [('project.project', False)], all_projects_account, True, False, False, False, True)"/>
|
||||
|
||||
@@ -48,7 +48,8 @@
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<menuitem action="action_header_img" id="menu_header_img" parent="base.menu_custom" sequence="14"/>
|
||||
<menuitem id="menu_webkit" name="Webkit" parent="base.menu_custom"/>
|
||||
<menuitem action="action_header_img" id="menu_header_img" parent="menu_webkit" sequence="14"/>
|
||||
|
||||
<record id="action_header_webkit" model="ir.actions.act_window">
|
||||
<field name="name">Webkit Headers/Footers</field>
|
||||
@@ -56,7 +57,7 @@
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<menuitem action="action_header_webkit" id="menu_header_webkit" parent="base.menu_custom" sequence="14"/>
|
||||
<menuitem action="action_header_webkit" id="menu_header_webkit" parent="menu_webkit" sequence="14"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -378,20 +378,25 @@ class Website(openerp.addons.web.controllers.main.Home):
|
||||
#------------------------------------------------------
|
||||
# Server actions
|
||||
#------------------------------------------------------
|
||||
@http.route(['/website/action/<id_or_xml_id>'], type='http', auth="public", website=True)
|
||||
def actions_server(self, id_or_xml_id, **post):
|
||||
|
||||
@http.route('/website/action/<path_or_xml_id_or_id>', type='http', auth="public", website=True)
|
||||
def actions_server(self, path_or_xml_id_or_id, **post):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
res, action_id, action = None, None, None
|
||||
ServerActions = request.registry['ir.actions.server']
|
||||
|
||||
# find the action_id, either an int, an int into a basestring, or an xml_id
|
||||
if isinstance(id_or_xml_id, basestring) and '.' in id_or_xml_id:
|
||||
action_id = request.registry['ir.model.data'].xmlid_to_res_id(request.cr, request.uid, id_or_xml_id, raise_if_not_found=False)
|
||||
else:
|
||||
# find the action_id: either an xml_id, the path, or an ID
|
||||
if isinstance(path_or_xml_id_or_id, basestring) and '.' in path_or_xml_id_or_id:
|
||||
action_id = request.registry['ir.model.data'].xmlid_to_res_id(request.cr, request.uid, path_or_xml_id_or_id, raise_if_not_found=False)
|
||||
if not action_id:
|
||||
action_ids = ServerActions.search(cr, uid, [('website_path', '=', path_or_xml_id_or_id), ('website_published', '=', True)], context=context)
|
||||
action_id = action_ids and action_ids[0] or None
|
||||
if not action_id:
|
||||
try:
|
||||
action_id = int(id_or_xml_id)
|
||||
action_id = int(path_or_xml_id_or_id)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
# check it effectively exists
|
||||
if action_id:
|
||||
action_ids = ServerActions.exists(cr, uid, [action_id], context=context)
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
<field name="name">Website Partner Post and Thanks Demo</field>
|
||||
<field name="condition">True</field>
|
||||
<field name="website_published" eval="True"/>
|
||||
<field name="website_path">partner_thanks</field>
|
||||
<field name="model_id" ref="base.model_res_partner"/>
|
||||
<field name="code">
|
||||
partner_id, partner = False, None
|
||||
@@ -118,6 +119,7 @@ response = request.website.render("website.template_partner_post", values)
|
||||
<field name="name">Website Partners Comment Form</field>
|
||||
<field name="condition">True</field>
|
||||
<field name="website_published" eval="True"/>
|
||||
<field name="website_path">partner_comment</field>
|
||||
<field name="model_id" ref="base.model_res_partner"/>
|
||||
<field name="code">
|
||||
partner_ids = pool['res.partner'].search(cr, uid, [('customer', '=', True)], context=context)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import urlparse
|
||||
|
||||
from openerp.addons.web.http import request
|
||||
from openerp.osv import fields, osv
|
||||
|
||||
@@ -9,15 +11,43 @@ class actions_server(osv.Model):
|
||||
_name = 'ir.actions.server'
|
||||
_inherit = ['ir.actions.server']
|
||||
|
||||
def _compute_website_url(self, cr, uid, id, website_path, xml_id, context=None):
|
||||
base_url = self.pool['ir.config_parameter'].get_param(cr, uid, 'web.base.url', context=context)
|
||||
link = website_path or xml_id or (id and '%d' % id) or ''
|
||||
if base_url and link:
|
||||
path = '%s/%s' % ('/website/action', link)
|
||||
return '%s' % urlparse.urljoin(base_url, path)
|
||||
return ''
|
||||
|
||||
def _get_website_url(self, cr, uid, ids, name, args, context=None):
|
||||
res = dict.fromkeys(ids, False)
|
||||
for action in self.browse(cr, uid, ids, context=context):
|
||||
if action.state == 'code' and action.website_published:
|
||||
res[action.id] = self._compute_website_url(cr, uid, action.id, action.website_path, action.xml_id, context=context)
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'xml_id': fields.function(
|
||||
osv.osv.get_xml_id, type='char', string="External ID",
|
||||
help="ID of the action if defined in a XML file"),
|
||||
'website_path': fields.char('Website Path'),
|
||||
'website_url': fields.function(
|
||||
_get_website_url, type='char', string='Website URL',
|
||||
help='The full URL to access the server action through the website.'),
|
||||
'website_published': fields.boolean(
|
||||
'Available on the Website',
|
||||
help='A code server action can be executed from the website, using a dedicated'
|
||||
'controller. The address is <base>/website/action/<id_or_xml_id>.'
|
||||
'controller. The address is <base>/website/action/<website_path>.'
|
||||
'Set this field as True to allow users to run this action. If it'
|
||||
'set to is False the action cannot be run through the website.'),
|
||||
}
|
||||
|
||||
def on_change_website_path(self, cr, uid, ids, website_path, xml_id, context=None):
|
||||
values = {
|
||||
'website_url': self._compute_website_url(cr, uid, ids[0], website_path, xml_id, context=context)
|
||||
}
|
||||
return {'value': values}
|
||||
|
||||
def _get_eval_context(self, cr, uid, action, context=None):
|
||||
""" Override to add the request object in eval_context. """
|
||||
eval_context = super(actions_server, self)._get_eval_context(cr, uid, action, context=context)
|
||||
|
||||
@@ -6,10 +6,43 @@
|
||||
<field name="name">ir.actions.server.form.website</field>
|
||||
<field name="model">ir.actions.server</field>
|
||||
<field name="inherit_id" ref="base.view_server_action_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//field[@name='state']" position="after">
|
||||
<field name="website_published"
|
||||
attrs="{'invisible': [('state', '!=', 'code')]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='sequence']" position="after">
|
||||
<field name="xml_id" invisible="1"/>
|
||||
<field name="website_path"
|
||||
on_change="on_change_website_path(website_path, xml_id, context)"
|
||||
attrs="{'invisible': ['|', ('website_published', '!=', True), ('state', '!=', 'code')]}"/>
|
||||
<field name="website_url" readonly="1"
|
||||
attrs="{'invisible': ['|', ('website_published', '!=', True), ('state', '!=', 'code')]}"/>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_server_action_tree_website">
|
||||
<field name="name">ir.actions.server.tree.website</field>
|
||||
<field name="model">ir.actions.server</field>
|
||||
<field name="inherit_id" ref="base.view_server_action_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='sequence']" position="after">
|
||||
<field name="website_url"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_server_action_search_website">
|
||||
<field name="name">ir.actions.server.search.website</field>
|
||||
<field name="model">ir.actions.server</field>
|
||||
<field name="inherit_id" ref="base.view_server_action_search"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='state']" position="after">
|
||||
<field name="website_published"
|
||||
attrs="{'invisible': [('state', '!=', 'code')]}"/>
|
||||
<filter string="Website" name="website"
|
||||
domain="[('website_published', '=', True), ('state', '=', 'code')]"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user