[MERGE] Merged with main branch
bzr revid: pso@tinyerp.com-20120820063058-rkyh4dj3vmdoikjv
This commit is contained in:
commit
001ee407e5
|
@ -82,6 +82,7 @@
|
|||
'demo_xml': [
|
||||
'base_demo.xml',
|
||||
'res/res_partner_demo.xml',
|
||||
'res/res_partner_demo.yml',
|
||||
'res/res_widget_demo.xml',
|
||||
],
|
||||
'test': [
|
||||
|
|
|
@ -146,17 +146,15 @@ select setval('ir_ui_menu_id_seq', 2);
|
|||
|
||||
CREATE TABLE res_users (
|
||||
id serial NOT NULL,
|
||||
name varchar(64) not null,
|
||||
active boolean default True,
|
||||
login varchar(64) NOT NULL UNIQUE,
|
||||
password varchar(64) default null,
|
||||
email varchar(64) default null,
|
||||
context_tz varchar(64) default null,
|
||||
signature text,
|
||||
context_lang varchar(64) default '',
|
||||
tz varchar(64) default null,
|
||||
lang varchar(64) default '',
|
||||
-- No FK references below, will be added later by ORM
|
||||
-- (when the destination rows exist)
|
||||
company_id int,
|
||||
partner_id int,
|
||||
primary key(id)
|
||||
);
|
||||
alter table res_users add constraint res_users_login_uniq unique (login);
|
||||
|
@ -385,7 +383,7 @@ CREATE TABLE ir_model_relation (
|
|||
-- Users
|
||||
---------------------------------
|
||||
|
||||
insert into res_users (id,login,password,name,active,company_id,context_lang) values (1,'admin','admin','Administrator',True,1,'en_US');
|
||||
insert into res_users (id,login,password,active,company_id,partner_id,lang) values (1,'admin','admin',True,1,1,'en_US');
|
||||
insert into ir_model_data (name,module,model,noupdate,res_id) values ('user_root','base','res.users',True,1);
|
||||
|
||||
-- Compatibility purpose, to remove V6.0
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
<record id="view_menu" model="ir.ui.view">
|
||||
<field name="name">ir.ui.menu.tree</field>
|
||||
<field name="model">ir.ui.menu</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Menu" toolbar="1">
|
||||
<field icon="icon" name="name"/>
|
||||
|
@ -36,6 +35,12 @@
|
|||
<field name="company_id" eval="None"/>
|
||||
<field name="customer" eval="False"/>
|
||||
<field name="is_company" eval="True"/>
|
||||
<field name="street"></field>
|
||||
<field name="city"></field>
|
||||
<field name="zip"></field>
|
||||
<field name="phone"></field>
|
||||
<field name="email">info@yourcompany.com</field>
|
||||
<field name="website">www.yourcompany.com</field>
|
||||
</record>
|
||||
|
||||
<!-- Currencies -->
|
||||
|
@ -57,24 +62,33 @@
|
|||
<record id="main_company" model="res.company">
|
||||
<field name="name">Your Company</field>
|
||||
<field name="partner_id" ref="main_partner"/>
|
||||
<field name="rml_footer1">Web: www.companyname.com - Tel: +1-212-555-12345</field>
|
||||
<field name="rml_footer2">IBAN: XX12 3456 7890 1234 5678 - SWIFT: SWIFTCODE - VAT: Company vat number</field>
|
||||
<field name="rml_header1">Your Company Slogan</field>
|
||||
<field name="rml_footer1">Web: http://www.yourcompany.com - Tel: +33 1 49 51 23 94</field>
|
||||
<field name="rml_footer2">Bank Accounts... to be configured in menu Settings > Accounting/Invoicing.</field>
|
||||
<field name="currency_id" ref="base.EUR"/>
|
||||
</record>
|
||||
|
||||
<record model="res.users" id="base.user_root">
|
||||
<field name="signature">Administrator</field>
|
||||
<record model="res.partner" id="base.partner_root">
|
||||
<field name="name">Administrator</field>
|
||||
<field name="company_id" ref="main_company"/>
|
||||
<field name="customer" eval="False"/>
|
||||
</record>
|
||||
|
||||
<record model="res.users" id="base.user_root">
|
||||
<field name="partner_id" ref="base.partner_root"/>
|
||||
<field name="company_id" ref="main_company"/>
|
||||
<field name="menu_id" ref="action_menu_admin"/>
|
||||
<field name="company_ids" eval="[(4, ref('main_company'))]"/>
|
||||
<field name="menu_id" ref="action_menu_admin"/>
|
||||
<field name="signature">Administrator</field>
|
||||
</record>
|
||||
|
||||
<record id="main_partner" model="res.partner">
|
||||
<field name="company_id" ref="main_company"/>
|
||||
</record>
|
||||
|
||||
<record id="EUR" model="res.currency">
|
||||
<field name="company_id" ref="main_company"/>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -1,19 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
|
||||
<record id="demo_address" model="res.partner">
|
||||
<field name="name">Fabien D'souza</field>
|
||||
<field name="street">Chaussee de Namur</field>
|
||||
<field name="zip">1367</field>
|
||||
<field name="city">Gerompont</field>
|
||||
<field name="phone">(+32).81.81.37.00</field>
|
||||
<field name="type">default</field>
|
||||
<field model="res.country" name="country_id" ref="be"/>
|
||||
<!-- Company ID will be set later -->
|
||||
<field name="company_id" eval="None"/>
|
||||
</record>
|
||||
|
||||
<record id="user_demo" model="res.users">
|
||||
<field name="login">demo</field>
|
||||
<field name="password">demo</field>
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
<data noupdate="1">
|
||||
<!-- The Following currency rates are considered as on 1st Jan,2010 against EUR. -->
|
||||
<!-- Currencies -->
|
||||
<record id="EUR" model="res.currency">
|
||||
<field name="company_id" ref="main_company"/>
|
||||
</record>
|
||||
<record id="USD" model="res.currency">
|
||||
<field name="name">USD</field>
|
||||
<field name="symbol">$</field>
|
||||
|
@ -2312,4 +2309,4 @@
|
|||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
</openerp>
|
||||
|
|
|
@ -7,14 +7,15 @@ msgstr ""
|
|||
"Project-Id-Version: OpenERP Server 5.0.4\n"
|
||||
"Report-Msgid-Bugs-To: support@openerp.com\n"
|
||||
"POT-Creation-Date: 2012-02-08 00:44+0000\n"
|
||||
"PO-Revision-Date: 2012-02-16 22:06+0000\n"
|
||||
"Last-Translator: Davide Corio - agilebg.com <davide.corio@agilebg.com>\n"
|
||||
"PO-Revision-Date: 2012-08-10 18:42+0000\n"
|
||||
"Last-Translator: Leonardo Pistone - Agile BG - Domsense "
|
||||
"<leonardo.pistone@domsense.com>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2012-07-19 04:40+0000\n"
|
||||
"X-Generator: Launchpad (build 15637)\n"
|
||||
"X-Launchpad-Export-Date: 2012-08-11 05:45+0000\n"
|
||||
"X-Generator: Launchpad (build 15780)\n"
|
||||
|
||||
#. module: base
|
||||
#: model:res.country,name:base.sh
|
||||
|
@ -849,6 +850,10 @@ msgid ""
|
|||
"Launch Manually Once: after hacing been launched manually, it sets "
|
||||
"automatically to Done."
|
||||
msgstr ""
|
||||
"Manuale: Esegui manualmente\n"
|
||||
"Automatico: Viene eseguito ogni volta che il sistema viene riconfigurato \n"
|
||||
"Esegui manualmente una volta sola: una volta lanciata l'esecuzione, lo stato "
|
||||
"viene impostato autmaticamente su \"Eseguito\""
|
||||
|
||||
#. module: base
|
||||
#: selection:base.language.install,lang:0
|
||||
|
@ -1593,7 +1598,7 @@ msgstr "Login"
|
|||
#: model:ir.actions.act_window,name:base.action_wizard_update_translations
|
||||
#: model:ir.ui.menu,name:base.menu_wizard_update_translations
|
||||
msgid "Synchronize Terms"
|
||||
msgstr ""
|
||||
msgstr "Sincronizza Termini"
|
||||
|
||||
#. module: base
|
||||
#: view:ir.actions.server:0
|
||||
|
@ -2980,7 +2985,7 @@ msgstr "Armenia"
|
|||
#: model:ir.actions.act_window,name:base.ir_property_form
|
||||
#: model:ir.ui.menu,name:base.menu_ir_property_form_all
|
||||
msgid "Configuration Parameters"
|
||||
msgstr "Parametri Configurazione"
|
||||
msgstr "Parametri di configurazione"
|
||||
|
||||
#. module: base
|
||||
#: constraint:ir.cron:0
|
||||
|
@ -3077,7 +3082,7 @@ msgstr ""
|
|||
#. module: base
|
||||
#: model:ir.module.module,shortdesc:base.module_wiki_quality_manual
|
||||
msgid "Wiki: Quality Manual"
|
||||
msgstr ""
|
||||
msgstr "Wiki: Manuale della Qualità"
|
||||
|
||||
#. module: base
|
||||
#: selection:ir.actions.act_window.view,view_mode:0
|
||||
|
@ -3105,7 +3110,7 @@ msgstr "Settore Risorse Umane"
|
|||
#. module: base
|
||||
#: model:ir.ui.menu,name:base.menu_dashboard_admin
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
msgstr "Dashboard di Amministrazione"
|
||||
|
||||
#. module: base
|
||||
#: code:addons/orm.py:4408
|
||||
|
@ -3748,7 +3753,7 @@ msgstr ""
|
|||
#. module: base
|
||||
#: model:ir.module.category,name:base.module_category_human_resources
|
||||
msgid "Human Resources"
|
||||
msgstr ""
|
||||
msgstr "Risorse Umane"
|
||||
|
||||
#. module: base
|
||||
#: model:ir.actions.act_window,name:base.action_country
|
||||
|
@ -3808,7 +3813,7 @@ msgstr "Partita IVA"
|
|||
#. module: base
|
||||
#: field:res.users,new_password:0
|
||||
msgid "Set password"
|
||||
msgstr ""
|
||||
msgstr "Nuova password"
|
||||
|
||||
#. module: base
|
||||
#: view:res.lang:0
|
||||
|
@ -4737,7 +4742,7 @@ msgstr "Kenia"
|
|||
#: model:ir.actions.act_window,name:base.action_translation
|
||||
#: model:ir.ui.menu,name:base.menu_action_translation
|
||||
msgid "Translated Terms"
|
||||
msgstr ""
|
||||
msgstr "Termini Tradotti"
|
||||
|
||||
#. module: base
|
||||
#: view:res.partner.event:0
|
||||
|
@ -6368,7 +6373,7 @@ msgstr "Menu"
|
|||
#. module: base
|
||||
#: selection:ir.actions.todo,type:0
|
||||
msgid "Launch Manually Once"
|
||||
msgstr ""
|
||||
msgstr "Esegui manualmente una volta sola"
|
||||
|
||||
#. module: base
|
||||
#: model:ir.module.category,name:base.module_category_hidden
|
||||
|
@ -6741,6 +6746,8 @@ msgid ""
|
|||
"password, otherwise leave empty. After a change of password, the user has to "
|
||||
"login again."
|
||||
msgstr ""
|
||||
"Per modificare la password scrivila qui, altrimenti lascia il campo vuoto. "
|
||||
"Dopo aver cambiato la password, l'utente deve fare nuovamente login."
|
||||
|
||||
#. module: base
|
||||
#: view:publisher_warranty.contract:0
|
||||
|
@ -6929,7 +6936,7 @@ msgstr ""
|
|||
#. module: base
|
||||
#: view:ir.property:0
|
||||
msgid "Parameters that are used by all resources."
|
||||
msgstr ""
|
||||
msgstr "Parametri utilizzati da tutte le risorse"
|
||||
|
||||
#. module: base
|
||||
#: model:res.country,name:base.mz
|
||||
|
@ -9394,7 +9401,7 @@ msgstr ""
|
|||
#: model:ir.model,name:base.model_ir_model
|
||||
#: model:ir.ui.menu,name:base.ir_model_model_menu
|
||||
msgid "Models"
|
||||
msgstr ""
|
||||
msgstr "Modelli"
|
||||
|
||||
#. module: base
|
||||
#: code:addons/base/ir/ir_cron.py:292
|
||||
|
@ -9405,7 +9412,7 @@ msgstr ""
|
|||
#. module: base
|
||||
#: selection:ir.actions.todo,type:0
|
||||
msgid "Launch Manually"
|
||||
msgstr ""
|
||||
msgstr "Esegui manualmente"
|
||||
|
||||
#. module: base
|
||||
#: model:res.country,name:base.be
|
||||
|
@ -10753,7 +10760,7 @@ msgstr "Nazione"
|
|||
#. module: base
|
||||
#: model:ir.ui.menu,name:base.next_id_5
|
||||
msgid "Sequences & Identifiers"
|
||||
msgstr ""
|
||||
msgstr "Sequenze e Identificatori"
|
||||
|
||||
#. module: base
|
||||
#: model:ir.module.module,description:base.module_l10n_th
|
||||
|
@ -12636,7 +12643,7 @@ msgstr "ir.values"
|
|||
#. module: base
|
||||
#: model:res.groups,name:base.group_no_one
|
||||
msgid "Technical Features"
|
||||
msgstr ""
|
||||
msgstr "Funzionalità tecniche"
|
||||
|
||||
#. module: base
|
||||
#: selection:base.language.install,lang:0
|
||||
|
@ -12656,7 +12663,7 @@ msgstr ""
|
|||
#: view:ir.model.data:0
|
||||
#: model:ir.ui.menu,name:base.ir_model_data_menu
|
||||
msgid "External Identifiers"
|
||||
msgstr ""
|
||||
msgstr "Identificatori Esterni"
|
||||
|
||||
#. module: base
|
||||
#: model:res.groups,name:base.group_sale_salesman
|
||||
|
@ -12950,6 +12957,7 @@ msgid ""
|
|||
"Please define at least one SMTP server, or provide the SMTP parameters "
|
||||
"explicitly."
|
||||
msgstr ""
|
||||
"Definire almeno un server SMTP, o fornire esplicitamente i parametri SMTP"
|
||||
|
||||
#. module: base
|
||||
#: view:ir.attachment:0
|
||||
|
@ -12993,7 +13001,7 @@ msgstr "Gabon"
|
|||
#. module: base
|
||||
#: model:res.groups,name:base.group_multi_company
|
||||
msgid "Multi Companies"
|
||||
msgstr ""
|
||||
msgstr "Multi-azienda"
|
||||
|
||||
#. module: base
|
||||
#: view:ir.model:0
|
||||
|
@ -13166,7 +13174,7 @@ msgstr "Varie"
|
|||
#: view:ir.mail_server:0
|
||||
#: model:ir.ui.menu,name:base.menu_mail_servers
|
||||
msgid "Outgoing Mail Servers"
|
||||
msgstr ""
|
||||
msgstr "Server della Posta in Uscita"
|
||||
|
||||
#. module: base
|
||||
#: model:res.country,name:base.cn
|
||||
|
|
|
@ -7,14 +7,14 @@ msgstr ""
|
|||
"Project-Id-Version: OpenERP Server 5.0.0\n"
|
||||
"Report-Msgid-Bugs-To: support@openerp.com\n"
|
||||
"POT-Creation-Date: 2012-02-08 00:44+0000\n"
|
||||
"PO-Revision-Date: 2012-02-19 13:01+0000\n"
|
||||
"PO-Revision-Date: 2012-08-09 06:15+0000\n"
|
||||
"Last-Translator: Erwin <Unknown>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2012-07-19 04:38+0000\n"
|
||||
"X-Generator: Launchpad (build 15637)\n"
|
||||
"X-Launchpad-Export-Date: 2012-08-10 04:58+0000\n"
|
||||
"X-Generator: Launchpad (build 15761)\n"
|
||||
|
||||
#. module: base
|
||||
#: model:res.country,name:base.sh
|
||||
|
@ -1443,7 +1443,7 @@ msgstr ""
|
|||
"U kunt de navolgende extra data toevoegen aan een verkooporder:\n"
|
||||
"* Aanvraagdatum\n"
|
||||
"* Bevestigde datum\n"
|
||||
"* Effectieve datum\n"
|
||||
"* Boek datum\n"
|
||||
|
||||
#. module: base
|
||||
#: model:ir.module.module,shortdesc:base.module_account_sequence
|
||||
|
@ -8110,7 +8110,7 @@ msgstr "Kenmerk"
|
|||
#. module: base
|
||||
#: model:ir.module.module,shortdesc:base.module_analytic
|
||||
msgid "Analytic Accounting"
|
||||
msgstr "Kostenplaats boekhouding"
|
||||
msgstr "Kostenplaatsen"
|
||||
|
||||
#. module: base
|
||||
#: view:ir.actions.report.xml:0
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
<record id="values_view_form_action" model="ir.ui.view">
|
||||
<field name="name">ir.values.form.action</field>
|
||||
<field name="model">ir.values</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Action Bindings" version="7.0">
|
||||
<group>
|
||||
|
@ -29,7 +28,6 @@
|
|||
<record id="values_view_form_defaults" model="ir.ui.view">
|
||||
<field name="name">ir.values.form.defaults</field>
|
||||
<field name="model">ir.values</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="User-defined Defaults" version="7.0">
|
||||
<group>
|
||||
|
@ -52,7 +50,6 @@
|
|||
<record id="values_view_tree_action" model="ir.ui.view">
|
||||
<field name="name">ir.values.tree.action</field>
|
||||
<field name="model">ir.values</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Action Bindings/Defaults">
|
||||
<field name="name"/>
|
||||
|
@ -65,7 +62,6 @@
|
|||
<record id="values_view_search_action" model="ir.ui.view">
|
||||
<field name="name">ir.values.search.action</field>
|
||||
<field name="model">ir.values</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Client Actions">
|
||||
<field name="name"
|
||||
|
@ -130,7 +126,6 @@
|
|||
<record id="sequence_view" model="ir.ui.view">
|
||||
<field name="name">ir.sequence.form</field>
|
||||
<field name="model">ir.sequence</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Sequences" version="7.0">
|
||||
<sheet>
|
||||
|
@ -179,7 +174,6 @@
|
|||
<record id="sequence_view_tree" model="ir.ui.view">
|
||||
<field name="name">ir.sequence.tree</field>
|
||||
<field name="model">ir.sequence</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Sequences">
|
||||
<field name="code"/>
|
||||
|
@ -197,7 +191,6 @@
|
|||
<record id="view_sequence_search" model="ir.ui.view">
|
||||
<field name="name">ir.sequence.search</field>
|
||||
<field name="model">ir.sequence</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Sequences">
|
||||
<field name="name" string="Sequence"/>
|
||||
|
@ -223,7 +216,6 @@
|
|||
<record id="sequence_type_form_view" model="ir.ui.view">
|
||||
<field name="name">ir.sequence.type.form</field>
|
||||
<field name="model">ir.sequence.type</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Sequence Type" version="7.0">
|
||||
<sheet>
|
||||
|
@ -239,7 +231,6 @@
|
|||
<record id="sequence_type_tree_view" model="ir.ui.view">
|
||||
<field name="name">ir.sequence.type.tree</field>
|
||||
<field name="model">ir.sequence.type</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Sequence Type">
|
||||
<field name="name"/>
|
||||
|
@ -251,7 +242,6 @@
|
|||
<record id="view_sequence_type_search" model="ir.ui.view">
|
||||
<field name="name">ir.sequence.type.search</field>
|
||||
<field name="model">ir.sequence.type</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Sequences Type">
|
||||
<field name="name" filter_domain="['|', ('name','ilike',self), ('code','ilike',self)]" string="Sequence Type"/>
|
||||
|
@ -276,7 +266,6 @@
|
|||
<record id="action_view" model="ir.ui.view">
|
||||
<field name="name">ir.actions.actions</field>
|
||||
<field name="model">ir.actions.actions</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Action" version="7.0">
|
||||
<group>
|
||||
|
@ -290,7 +279,6 @@
|
|||
<record id="action_view_tree" model="ir.ui.view">
|
||||
<field name="name">ir.actions.actions.tree</field>
|
||||
<field name="model">ir.actions.actions</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Action">
|
||||
<field name="name"/>
|
||||
|
@ -301,7 +289,6 @@
|
|||
<record id="action_view_search" model="ir.ui.view">
|
||||
<field name="name">ir.actions.actions.search</field>
|
||||
<field name="model">ir.actions.actions</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Action">
|
||||
<field name="name" filter_domain="['|', ('name','ilike',self), ('type','ilike',self)]" string="Action"/>
|
||||
|
@ -327,7 +314,6 @@
|
|||
<record id="act_report_xml_view" model="ir.ui.view">
|
||||
<field name="name">ir.actions.report.xml</field>
|
||||
<field name="model">ir.actions.report.xml</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Report" version="7.0">
|
||||
<group>
|
||||
|
@ -372,7 +358,6 @@
|
|||
<record id="act_report_xml_view_tree" model="ir.ui.view">
|
||||
<field name="name">ir.actions.report.xml.tree</field>
|
||||
<field name="model">ir.actions.report.xml</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Report xml">
|
||||
<field name="name"/>
|
||||
|
@ -387,7 +372,6 @@
|
|||
<record id="act_report_xml_search_view" model="ir.ui.view">
|
||||
<field name="name">ir.actions.report.xml.search</field>
|
||||
<field name="model">ir.actions.report.xml</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Report Xml">
|
||||
<field name="name"
|
||||
|
@ -413,7 +397,6 @@
|
|||
<record id="view_window_action_tree" model="ir.ui.view">
|
||||
<field name="name">ir.actions.windows.tree</field>
|
||||
<field name="model">ir.actions.act_window</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Open Window">
|
||||
<field name="name"/>
|
||||
|
@ -428,7 +411,6 @@
|
|||
<record id="view_window_action_form" model="ir.ui.view">
|
||||
<field name="name">ir.actions.windows.form</field>
|
||||
<field name="model">ir.actions.act_window</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Open a Window" version="7.0">
|
||||
<group>
|
||||
|
@ -491,7 +473,6 @@
|
|||
<record id="view_window_action_search" model="ir.ui.view">
|
||||
<field name="name">ir.actions.windows.search</field>
|
||||
<field name="model">ir.actions.act_window</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Open a Window">
|
||||
<field name="name" filter_domain="['|', ('name','ilike',self), ('res_model','ilike',self)]" string="Action"/>
|
||||
|
@ -527,7 +508,6 @@
|
|||
<record id="act_wizard_view_tree" model="ir.ui.view">
|
||||
<field name="name">ir.actions.wizard.tree</field>
|
||||
<field name="model">ir.actions.wizard</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Wizard">
|
||||
<field name="name"/>
|
||||
|
@ -540,7 +520,6 @@
|
|||
<record id="act_wizard_view" model="ir.ui.view">
|
||||
<field name="name">ir.actions.wizard</field>
|
||||
<field name="model">ir.actions.wizard</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Wizards" version="7.0">
|
||||
<group col="4">
|
||||
|
@ -558,7 +537,6 @@
|
|||
<record id="act_wizard_search_view" model="ir.ui.view">
|
||||
<field name="name">ir.actions.wizard.search</field>
|
||||
<field name="model">ir.actions.wizard</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Wizards">
|
||||
<field name="name"
|
||||
|
@ -582,7 +560,6 @@
|
|||
<record model="ir.ui.view" id="view_ir_needaction_users_rel_tree">
|
||||
<field name="name">ir.needaction_users_rel.tree</field>
|
||||
<field name="model">ir.needaction_users_rel</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="sequence">10</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Subscription">
|
||||
|
@ -607,7 +584,6 @@
|
|||
<record id="view_view_form" model="ir.ui.view">
|
||||
<field name="name">ir.ui.view</field>
|
||||
<field name="model">ir.ui.view</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Views" version="7.0">
|
||||
<sheet>
|
||||
|
@ -633,7 +609,6 @@
|
|||
<record id="view_view_tree" model="ir.ui.view">
|
||||
<field name="name">ir.ui.view.tree</field>
|
||||
<field name="model">ir.ui.view</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Views">
|
||||
<field name="priority" string="Sequence"/>
|
||||
|
@ -649,7 +624,6 @@
|
|||
<record id="view_view_search" model="ir.ui.view">
|
||||
<field name="name">ir.ui.view.search</field>
|
||||
<field name="model">ir.ui.view</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Views">
|
||||
<field name="name" filter_domain="['|', ('name','ilike',self), ('model','ilike',self)]" string="View"/>
|
||||
|
@ -686,7 +660,6 @@
|
|||
<record id="view_view_custom_search" model="ir.ui.view">
|
||||
<field name="name">ir.ui.view.custom.search</field>
|
||||
<field name="model">ir.ui.view.custom</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Customized Views">
|
||||
<field name="user_id"/>
|
||||
|
@ -697,7 +670,6 @@
|
|||
<record id="view_view_custom_form" model="ir.ui.view">
|
||||
<field name="name">ir.ui.view.custom.form</field>
|
||||
<field name="model">ir.ui.view.custom</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Customized Views" version="7.0">
|
||||
<sheet>
|
||||
|
@ -713,7 +685,6 @@
|
|||
<record id="view_view_custom_tree" model="ir.ui.view">
|
||||
<field name="name">ir.ui.view.custom.tree</field>
|
||||
<field name="model">ir.ui.view.custom</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Customized Views">
|
||||
<field name="user_id"/>
|
||||
|
@ -734,7 +705,6 @@
|
|||
<record id="view_attachment_form" model="ir.ui.view">
|
||||
<field name="name">ir.attachment.view</field>
|
||||
<field name="model">ir.attachment</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Attachments" version="7.0">
|
||||
<sheet>
|
||||
|
@ -773,7 +743,6 @@
|
|||
<record id="view_attachment_tree" model="ir.ui.view">
|
||||
<field name="name">ir.attachment.view.tree</field>
|
||||
<field name="model">ir.attachment</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Attachments">
|
||||
<field name="name"/>
|
||||
|
@ -788,7 +757,6 @@
|
|||
<record id="view_attachment_search" model="ir.ui.view">
|
||||
<field name="name">ir.attachment.search</field>
|
||||
<field name="model">ir.attachment</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Attachments">
|
||||
<field name="name" filter_domain="['|', ('name','ilike',self), ('datas_fname','ilike',self)]" string="Attachment"/>
|
||||
|
@ -831,7 +799,6 @@
|
|||
<record id="view_model_form" model="ir.ui.view">
|
||||
<field name="name">ir.model.form</field>
|
||||
<field name="model">ir.model</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Model Description" version="7.0">
|
||||
<sheet>
|
||||
|
@ -921,7 +888,6 @@
|
|||
<record id="view_model_tree" model="ir.ui.view">
|
||||
<field name="name">ir.model.tree</field>
|
||||
<field name="model">ir.model</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Model Description">
|
||||
<field name="model"/>
|
||||
|
@ -935,7 +901,6 @@
|
|||
<record id="view_model_search" model="ir.ui.view">
|
||||
<field name="name">ir.model.search</field>
|
||||
<field name="model">ir.model</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Model Description">
|
||||
<field name="name" filter_domain="['|', ('name','ilike',self), ('model','ilike',self)]" string="Model"/>
|
||||
|
@ -957,7 +922,6 @@
|
|||
<record id="view_model_fields_form" model="ir.ui.view">
|
||||
<field name="name">ir.model.fields.form</field>
|
||||
<field name="model">ir.model.fields</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Fields" version="7.0">
|
||||
<sheet>
|
||||
|
@ -1000,7 +964,6 @@
|
|||
<record id="view_model_fields_tree" model="ir.ui.view">
|
||||
<field name="name">ir.model.fields.tree</field>
|
||||
<field name="model">ir.model.fields</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Fields">
|
||||
<field name="name"/>
|
||||
|
@ -1015,7 +978,6 @@
|
|||
<record id="view_model_fields_search" model="ir.ui.view">
|
||||
<field name="name">ir.model.fields.search</field>
|
||||
<field name="model">ir.model.fields</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Fields">
|
||||
<field name="name" filter_domain="['|', ('name','ilike',self), ('field_description','ilike',self)]" string="Field"/>
|
||||
|
@ -1044,7 +1006,6 @@
|
|||
<record model="ir.ui.view" id="view_model_data_form">
|
||||
<field name="name">ir.model.data.form</field>
|
||||
<field name="model">ir.model.data</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="External Identifiers" version="7.0">
|
||||
<group>
|
||||
|
@ -1071,7 +1032,6 @@
|
|||
<record id="view_model_data_list" model="ir.ui.view">
|
||||
<field name="name">ir.model.data.list</field>
|
||||
<field name="model">ir.model.data</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="External Identifiers">
|
||||
<field name="complete_name"/>
|
||||
|
@ -1084,7 +1044,6 @@
|
|||
<record id="view_model_data_search" model="ir.ui.view">
|
||||
<field name="name">ir.model.data.search</field>
|
||||
<field name="model">ir.model.data</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="External Identifiers">
|
||||
<field name="name"
|
||||
|
@ -1106,7 +1065,6 @@
|
|||
<record model="ir.ui.view" id="view_model_constraint_form">
|
||||
<field name="name">ir.model.constraint.form</field>
|
||||
<field name="model">ir.model.constraint</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Model Constraints">
|
||||
<field name="type"/>
|
||||
|
@ -1123,7 +1081,6 @@
|
|||
<record id="view_model_constraint_list" model="ir.ui.view">
|
||||
<field name="name">ir.model.constraint.list</field>
|
||||
<field name="model">ir.model.constraint</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Model Constraints">
|
||||
<field name="type"/>
|
||||
|
@ -1137,7 +1094,6 @@
|
|||
<record model="ir.ui.view" id="view_model_relation_form">
|
||||
<field name="name">ir.model.relation.form</field>
|
||||
<field name="model">ir.model.relation</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="ManyToMany Relations">
|
||||
<field name="name"/>
|
||||
|
@ -1153,7 +1109,6 @@
|
|||
<record id="view_model_relation_list" model="ir.ui.view">
|
||||
<field name="name">ir.model.relation.list</field>
|
||||
<field name="model">ir.model.relation</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="ManyToMany Relations">
|
||||
<field name="name"/>
|
||||
|
@ -1214,7 +1169,6 @@
|
|||
<record id="view_translation_search" model="ir.ui.view">
|
||||
<field name="name">Translations</field>
|
||||
<field name="model">ir.translation</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Translations">
|
||||
<filter icon="terp-gdu-smart-failing"
|
||||
|
@ -1230,7 +1184,6 @@
|
|||
<record id="view_translation_form" model="ir.ui.view">
|
||||
<field name="name">Translations</field>
|
||||
<field name="model">ir.translation</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Translations" version="7.0">
|
||||
<sheet>
|
||||
|
@ -1257,7 +1210,6 @@
|
|||
<record id="view_translation_tree" model="ir.ui.view">
|
||||
<field name="name">Translations</field>
|
||||
<field name="model">ir.translation</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Translations">
|
||||
<field name="src"/>
|
||||
|
@ -1286,7 +1238,6 @@
|
|||
<record id="shortcut_form" model="ir.ui.view">
|
||||
<field name="name">ir.ui.view_sc</field>
|
||||
<field name="model">ir.ui.view_sc</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Shortcut" version="7.0">
|
||||
<group col="4">
|
||||
|
@ -1299,7 +1250,6 @@
|
|||
<record id="shortcut_tree" model="ir.ui.view">
|
||||
<field name="name">ir.ui.view_sc</field>
|
||||
<field name="model">ir.ui.view_sc</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Shortcut">
|
||||
<field name="name"/>
|
||||
|
@ -1311,7 +1261,6 @@
|
|||
<record id="edit_menu" model="ir.ui.view">
|
||||
<field name="name">ir.ui.menu.tree</field>
|
||||
<field name="model">ir.ui.menu</field>
|
||||
<field name="type">tree</field>
|
||||
<field eval="8" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Menu">
|
||||
|
@ -1324,7 +1273,6 @@
|
|||
<record id="edit_menu_access" model="ir.ui.view">
|
||||
<field name="name">ir.ui.menu.form2</field>
|
||||
<field name="model">ir.ui.menu</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Menu" version="7.0">
|
||||
<sheet>
|
||||
|
@ -1364,7 +1312,6 @@
|
|||
<record id="edit_menu_access_search" model="ir.ui.view">
|
||||
<field name="name">ir.ui.menu.search</field>
|
||||
<field name="model">ir.ui.menu</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Menu">
|
||||
<field name="name" string="Menu"/>
|
||||
|
@ -1389,7 +1336,6 @@
|
|||
<record id="ir_cron_view_tree" model="ir.ui.view">
|
||||
<field name="name">ir.cron.tree</field>
|
||||
<field name="model">ir.cron</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Scheduled Actions">
|
||||
<field name="priority" string="Sequence"/>
|
||||
|
@ -1406,7 +1352,6 @@
|
|||
<record id="ir_cron_view" model="ir.ui.view">
|
||||
<field name="name">ir.cron.form</field>
|
||||
<field name="model">ir.cron</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Scheduled Actions" version="7.0">
|
||||
<sheet>
|
||||
|
@ -1444,7 +1389,6 @@
|
|||
<record id="ir_cron_view_search" model="ir.ui.view">
|
||||
<field name="name">ir.cron.search</field>
|
||||
<field name="model">ir.cron</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Scheduled Actions">
|
||||
<field name="name" string="Scheduled Action"/>
|
||||
|
@ -1463,7 +1407,6 @@
|
|||
<record model="ir.ui.view" id="ir_cron_view_calendar">
|
||||
<field name="name">ir.cron.calendar</field>
|
||||
<field name="model">ir.cron</field>
|
||||
<field name="type">calendar</field>
|
||||
<field name="priority" eval="2"/>
|
||||
<field name="arch" type="xml">
|
||||
<calendar string="Scheduled Actions" date_start="nextcall" color="user_id">
|
||||
|
@ -1490,7 +1433,6 @@
|
|||
<record id="ir_access_view_tree" model="ir.ui.view">
|
||||
<field name="name">ir.model.access.tree</field>
|
||||
<field name="model">ir.model.access</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Access Controls" editable="bottom">
|
||||
<field name="name"/>
|
||||
|
@ -1506,7 +1448,6 @@
|
|||
<record id="ir_access_view_form" model="ir.ui.view">
|
||||
<field name="name">ir.model.access.form</field>
|
||||
<field name="model">ir.model.access</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Access Controls" version="7.0">
|
||||
<sheet>
|
||||
|
@ -1528,7 +1469,6 @@
|
|||
<record id="ir_access_view_search" model="ir.ui.view">
|
||||
<field name="name">ir.model.access.search</field>
|
||||
<field name="model">ir.model.access</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Access Controls">
|
||||
<field name="name" string="Access Control"/>
|
||||
|
@ -1561,7 +1501,6 @@
|
|||
<record id="view_rule_form" model="ir.ui.view">
|
||||
<field name="name">Record rules</field>
|
||||
<field name="model">ir.rule</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Record rules" version="7.0">
|
||||
<sheet>
|
||||
|
@ -1604,7 +1543,6 @@
|
|||
<record id="view_rule_tree" model="ir.ui.view">
|
||||
<field name="name">Record rules</field>
|
||||
<field name="model">ir.rule</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Record rules">
|
||||
<field name="model_id"/>
|
||||
|
@ -1621,7 +1559,6 @@
|
|||
<record id="view_rule_search" model="ir.ui.view">
|
||||
<field name="name">Record rules</field>
|
||||
<field name="model">ir.rule</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Record Rules">
|
||||
<field name="name" string="Record Rule"/>
|
||||
|
@ -1657,7 +1594,6 @@
|
|||
<record id="view_server_action_form" model="ir.ui.view">
|
||||
<field name="name">Server Action</field>
|
||||
<field name="model">ir.actions.server</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Server Action" version="7.0">
|
||||
<group>
|
||||
|
@ -1747,7 +1683,6 @@
|
|||
<record id="view_server_action_tree" model="ir.ui.view">
|
||||
<field name="name">Server Actions</field>
|
||||
<field name="model">ir.actions.server</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Server Actions">
|
||||
<field name="name"/>
|
||||
|
@ -1761,7 +1696,6 @@
|
|||
<record id="view_server_action_search" model="ir.ui.view">
|
||||
<field name="name">ir.actions.server.search</field>
|
||||
<field name="model">ir.actions.server</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Server Actions">
|
||||
<field name="name" string="Server Action"/>
|
||||
|
@ -1791,7 +1725,6 @@
|
|||
<record id="ir_actions_todo_tree" model="ir.ui.view">
|
||||
<field name="model">ir.actions.todo</field>
|
||||
<field name="name">Config Wizard Steps</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Config Wizard Steps">
|
||||
<field name="sequence"/>
|
||||
|
@ -1809,7 +1742,6 @@
|
|||
<record id="config_wizard_step_view_form" model="ir.ui.view">
|
||||
<field name="model">ir.actions.todo</field>
|
||||
<field name="name">Config Wizard Steps</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Config Wizard Steps" version="7.0">
|
||||
<header>
|
||||
|
@ -1839,7 +1771,6 @@
|
|||
<record id="config_wizard_step_view_search" model="ir.ui.view">
|
||||
<field name="model">ir.actions.todo</field>
|
||||
<field name="name">ir.actions.todo.select</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Actions">
|
||||
<filter string="To Do" name="todo" icon="terp-camera_test" domain=" [('state','=','open')]" help="Wizards to be Launched"/>
|
||||
|
@ -1875,7 +1806,6 @@
|
|||
<record model="ir.ui.view" id="ir_mail_server_form">
|
||||
<field name="name">ir.mail.server.form</field>
|
||||
<field name="model">ir.mail_server</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Outgoing Mail Servers" version="7.0">
|
||||
<sheet>
|
||||
|
@ -1902,7 +1832,6 @@
|
|||
<record model="ir.ui.view" id="ir_mail_server_list">
|
||||
<field name="name">ir.mail.server.list</field>
|
||||
<field name="model">ir.mail_server</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Outgoing Mail Servers">
|
||||
<field name="sequence"/>
|
||||
|
@ -1917,7 +1846,6 @@
|
|||
<record id="view_ir_mail_server_search" model="ir.ui.view">
|
||||
<field name="name">ir.mail.server.search</field>
|
||||
<field name="model">ir.mail_server</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Outgoing Mail Servers">
|
||||
<field name="name"
|
||||
|
|
|
@ -223,11 +223,11 @@ class act_window(osv.osv):
|
|||
help="Model name of the object to open in the view window"),
|
||||
'src_model': fields.char('Source Model', size=64,
|
||||
help="Optional model name of the objects on which this action should be visible"),
|
||||
'target': fields.selection([('current','Current Window'),('new','New Window'),('inline','Inline')], 'Target Window'),
|
||||
'view_type': fields.selection((('tree','Tree'),('form','Form')), string='View Type', required=True,
|
||||
help="View type: set to 'tree' for a hierarchical tree view, or 'form' for other views"),
|
||||
'target': fields.selection([('current','Current Window'),('new','New Window'),('inline','Inline Edit'),('inlineview','Inline View')], 'Target Window'),
|
||||
'view_mode': fields.char('View Mode', size=250, required=True,
|
||||
help="Comma-separated list of allowed view modes, such as 'form', 'tree', 'calendar', etc. (Default: tree,form)"),
|
||||
'view_type': fields.selection((('tree','Tree'),('form','Form')), string='View Type', required=True,
|
||||
help="View type: Tree type to use for the tree view, set to 'tree' for a hierarchical tree view, or 'form' for a regular list view"),
|
||||
'usage': fields.char('Action Usage', size=32,
|
||||
help="Used to filter menu and home actions from the user form."),
|
||||
'view_ids': fields.one2many('ir.actions.act_window.view', 'act_window_id', 'Views'),
|
||||
|
@ -625,8 +625,8 @@ class actions_server(osv.osv):
|
|||
|
||||
if not email_from:
|
||||
_logger.debug('--email-from command line option is not specified, using a fallback value instead.')
|
||||
if user.user_email:
|
||||
email_from = user.user_email
|
||||
if user.email:
|
||||
email_from = user.email
|
||||
else:
|
||||
email_from = "%s@%s" % (user.login, gethostname())
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<record model="ir.ui.view" id="view_ir_config_search">
|
||||
<field name="name">ir.config_parameter.search</field>
|
||||
<field name="model">ir.config_parameter</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="System Properties">
|
||||
<field name="key" string="Key"/>
|
||||
|
@ -16,7 +15,6 @@
|
|||
<record model="ir.ui.view" id="view_ir_config_list">
|
||||
<field name="name">ir.config_parameter.list</field>
|
||||
<field name="model">ir.config_parameter</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="System Parameters">
|
||||
<field name="key"/>
|
||||
|
@ -27,7 +25,6 @@
|
|||
<record model="ir.ui.view" id="view_ir_config_form">
|
||||
<field name="name">ir.config_parameter.form</field>
|
||||
<field name="model">ir.config_parameter</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="System Parameters" version="7.0">
|
||||
<sheet>
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
<record id="ir_filters_view_form" model="ir.ui.view">
|
||||
<field name="name">ir.filters.form</field>
|
||||
<field name="model">ir.filters</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Filters" version="7.0">
|
||||
<sheet>
|
||||
|
@ -35,7 +34,6 @@
|
|||
<record id="ir_filters_view_tree" model="ir.ui.view">
|
||||
<field name="name">ir.filters.tree</field>
|
||||
<field name="model">ir.filters</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Filters">
|
||||
<field name="name"/>
|
||||
|
@ -50,7 +48,6 @@
|
|||
<record id="ir_filters_view_search" model="ir.ui.view">
|
||||
<field name="name">ir.filters.search</field>
|
||||
<field name="model">ir.filters</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Filters">
|
||||
<field name="name" string="Filter Name"/>
|
||||
|
|
|
@ -24,6 +24,7 @@ from lxml import etree
|
|||
from tools import graph
|
||||
from tools.safe_eval import safe_eval as eval
|
||||
import tools
|
||||
from tools.view_validation import valid_view
|
||||
import os
|
||||
import logging
|
||||
|
||||
|
@ -47,11 +48,22 @@ view_custom()
|
|||
|
||||
class view(osv.osv):
|
||||
_name = 'ir.ui.view'
|
||||
|
||||
def _type_field(self, cr, uid, ids, name, args, context=None):
|
||||
result = {}
|
||||
for record in self.browse(cr, uid, ids, context):
|
||||
# Get the type from the inherited view if any.
|
||||
if record.inherit_id:
|
||||
result[record.id] = record.inherit_id.type
|
||||
else:
|
||||
result[record.id] = etree.fromstring(record.arch.encode('utf8')).tag
|
||||
return result
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('View Name',size=64, required=True),
|
||||
'model': fields.char('Object', size=64, required=True, select=True),
|
||||
'priority': fields.integer('Sequence', required=True),
|
||||
'type': fields.selection((
|
||||
'type': fields.function(_type_field, type='selection', selection=[
|
||||
('tree','Tree'),
|
||||
('form','Form'),
|
||||
('mdx','mdx'),
|
||||
|
@ -60,7 +72,7 @@ class view(osv.osv):
|
|||
('diagram','Diagram'),
|
||||
('gantt', 'Gantt'),
|
||||
('kanban', 'Kanban'),
|
||||
('search','Search')), 'View Type', required=True, select=True),
|
||||
('search','Search')], string='View Type', required=True, select=True, store=True),
|
||||
'arch': fields.text('View Architecture', required=True),
|
||||
'inherit_id': fields.many2one('ir.ui.view', 'Inherited View', ondelete='cascade', select=True),
|
||||
'field_parent': fields.char('Child Field',size=64),
|
||||
|
@ -76,6 +88,11 @@ class view(osv.osv):
|
|||
# Holds the RNG schema
|
||||
_relaxng_validator = None
|
||||
|
||||
def create(self, cr, uid, values, context=None):
|
||||
if 'type' in values:
|
||||
_logger.warning("Setting the `type` field is deprecated in the `ir.ui.view` model.")
|
||||
return super(osv.osv, self).create(cr, uid, values, context)
|
||||
|
||||
def _relaxng(self):
|
||||
if not self._relaxng_validator:
|
||||
frng = tools.file_open(os.path.join('base','rng','view.rng'))
|
||||
|
@ -123,6 +140,8 @@ class view(osv.osv):
|
|||
for error in validator.error_log:
|
||||
_logger.error(tools.ustr(error))
|
||||
return False
|
||||
if not valid_view(view_arch):
|
||||
return False
|
||||
return True
|
||||
|
||||
_constraints = [
|
||||
|
@ -133,7 +152,7 @@ class view(osv.osv):
|
|||
super(view, self)._auto_init(cr, context)
|
||||
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'ir_ui_view_model_type_inherit_id\'')
|
||||
if not cr.fetchone():
|
||||
cr.execute('CREATE INDEX ir_ui_view_model_type_inherit_id ON ir_ui_view (model, type, inherit_id)')
|
||||
cr.execute('CREATE INDEX ir_ui_view_model_type_inherit_id ON ir_ui_view (model, inherit_id)')
|
||||
|
||||
def get_inheriting_views_arch(self, cr, uid, view_id, model, context=None):
|
||||
"""Retrieves the architecture of views that inherit from the given view, from the sets of
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
<record id="view_model_menu_create" model="ir.ui.view">
|
||||
<field name="name">Create Menu</field>
|
||||
<field name="model">wizard.ir.model.menu.create</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Create Menu" version="7.0">
|
||||
<group>
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
<record id="view_workflow_form" model="ir.ui.view">
|
||||
<field name="name">workflow.form</field>
|
||||
<field name="model">workflow</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Workflow" version="7.0">
|
||||
<group col="4">
|
||||
|
@ -28,7 +27,6 @@
|
|||
<record id="view_workflow_search" model="ir.ui.view">
|
||||
<field name="name">workflow.search</field>
|
||||
<field name="model">workflow</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Workflow">
|
||||
<field name="name" filter_domain="['|', ('name','ilike',self), ('osv','ilike',self)]" string="Workflow"/>
|
||||
|
@ -39,7 +37,6 @@
|
|||
<record id="view_workflow_diagram" model="ir.ui.view">
|
||||
<field name="name">workflow.diagram</field>
|
||||
<field name="model">workflow</field>
|
||||
<field name="type">diagram</field>
|
||||
<field name="arch" type="xml">
|
||||
<diagram string="Workflow Editor">
|
||||
<node object="workflow.activity" shape="rectangle:subflow_id!=False" bgcolor="gray:flow_start==True;grey:flow_stop==True">
|
||||
|
@ -55,13 +52,13 @@
|
|||
<field name="act_to"/>
|
||||
<field name="signal"/>
|
||||
</arrow>
|
||||
<label string="When customizing a workflow, be sure you do not modify an existing node or arrow, but rather add new nodes or arrows. If you absolutly need to modify a node or arrow, you can only change fields that are empty or set to the default value. If you don't do that, your customization will be overwrited at the next update or upgrade to a future version of OpenERP."/>
|
||||
</diagram>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_workflow_tree" model="ir.ui.view">
|
||||
<field name="name">workflow.tree</field>
|
||||
<field name="model">workflow</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Workflow">
|
||||
<field name="name"/>
|
||||
|
@ -89,7 +86,6 @@
|
|||
<record id="view_workflow_activity_form" model="ir.ui.view">
|
||||
<field name="name">workflow.activity.form</field>
|
||||
<field name="model">workflow.activity</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Activity" version="7.0">
|
||||
<sheet>
|
||||
|
@ -145,7 +141,6 @@
|
|||
<record id="view_workflow_activity_tree" model="ir.ui.view">
|
||||
<field name="name">workflow.activity.tree</field>
|
||||
<field name="model">workflow.activity</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Activity">
|
||||
<field name="name"/>
|
||||
|
@ -160,7 +155,6 @@
|
|||
<record id="view_workflow_activity_search" model="ir.ui.view">
|
||||
<field name="name">workflow.activity.search</field>
|
||||
<field name="model">workflow.activity</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Workflow Activity">
|
||||
<field name="name" string="Workflow Activity"/>
|
||||
|
@ -197,7 +191,6 @@
|
|||
<record id="view_workflow_transition_form" model="ir.ui.view">
|
||||
<field name="name">workflow.transition.form</field>
|
||||
<field name="model">workflow.transition</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Transition" version="7.0">
|
||||
<sheet>
|
||||
|
@ -221,7 +214,6 @@
|
|||
<record id="view_workflow_transition_tree" model="ir.ui.view">
|
||||
<field name="name">workflow.transition.tree</field>
|
||||
<field name="model">workflow.transition</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Transition">
|
||||
<field name="act_from"/>
|
||||
|
@ -235,7 +227,6 @@
|
|||
<record id="view_workflow_transition_search" model="ir.ui.view">
|
||||
<field name="name">workflow.transition.search</field>
|
||||
<field name="model">workflow.transition</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Transition">
|
||||
<field name="signal" filter_domain="['|', ('signal','ilike',self), ('condition','ilike',self)]" string="Workflow Transition"/>
|
||||
|
@ -263,7 +254,6 @@
|
|||
<record id="view_workflow_instance_form" model="ir.ui.view">
|
||||
<field name="name">workflow.instance.form</field>
|
||||
<field name="model">workflow.instance</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Workflow Instances" version="7.0">
|
||||
<sheet>
|
||||
|
@ -280,7 +270,6 @@
|
|||
<record id="view_workflow_instance_tree" model="ir.ui.view">
|
||||
<field name="name">workflow.instance.tree</field>
|
||||
<field name="model">workflow.instance</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Workflow Instances">
|
||||
<field name="wkf_id"/>
|
||||
|
@ -293,7 +282,6 @@
|
|||
<record id="view_workflow_instance_search" model="ir.ui.view">
|
||||
<field name="name">workflow.instance.search</field>
|
||||
<field name="model">workflow.instance</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Workflow Instances">
|
||||
<field name="res_type" string="Resource Object"/>
|
||||
|
@ -324,7 +312,6 @@
|
|||
<record id="view_workflow_workitem_form" model="ir.ui.view">
|
||||
<field name="name">workflow.workitem.form</field>
|
||||
<field name="model">workflow.workitem</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Workflow Workitems" version="7.0">
|
||||
<sheet>
|
||||
|
@ -342,7 +329,6 @@
|
|||
<record id="view_workflow_workitem_tree" model="ir.ui.view">
|
||||
<field name="name">workflow.workitem.tree</field>
|
||||
<field name="model">workflow.workitem</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Workflow Workitems">
|
||||
<field name="wkf_id"/>
|
||||
|
@ -356,7 +342,6 @@
|
|||
<record id="view_workflow_workitem_search" model="ir.ui.view">
|
||||
<field name="name">workflow.workitem.search</field>
|
||||
<field name="model">workflow.workitem</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Workflow Workitems">
|
||||
<field name="state" string="State"/>
|
||||
|
|
|
@ -139,14 +139,17 @@ class module(osv.osv):
|
|||
# We use try except, because views or menus may not exist.
|
||||
try:
|
||||
res_mod_dic = res[module_rec.id]
|
||||
for v in view_obj.browse(cr, uid, imd_models.get('ir.ui.view', []), context=context):
|
||||
view_ids = imd_models.get('ir.ui.view', [])
|
||||
for v in view_obj.browse(cr, uid, view_ids, context=context):
|
||||
aa = v.inherit_id and '* INHERIT ' or ''
|
||||
res_mod_dic['views_by_module'].append(aa + v.name + '('+v.type+')')
|
||||
|
||||
for rx in report_obj.browse(cr, uid, imd_models.get('ir.actions.report.xml', []), context=context):
|
||||
report_ids = imd_models.get('ir.actions.report.xml', [])
|
||||
for rx in report_obj.browse(cr, uid, report_ids, context=context):
|
||||
res_mod_dic['reports_by_module'].append(rx.name)
|
||||
|
||||
for um in menu_obj.browse(cr, uid, imd_models.get('ir.ui.menu', []), context=context):
|
||||
menu_ids = imd_models.get('ir.ui.menu', [])
|
||||
for um in menu_obj.browse(cr, uid, menu_ids, context=context):
|
||||
res_mod_dic['menus_by_module'].append(um.complete_name)
|
||||
except KeyError, e:
|
||||
_logger.warning(
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
<record id="view_module_category_form" model="ir.ui.view">
|
||||
<field name="name">ir.module.category.form</field>
|
||||
<field name="model">ir.module.category</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Module Category" version="7.0">
|
||||
<group col="4">
|
||||
|
@ -23,7 +22,6 @@
|
|||
<record id="view_module_category_tree" model="ir.ui.view">
|
||||
<field name="name">ir.module.category.tree</field>
|
||||
<field name="model">ir.module.category</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="field_parent">child_ids</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Module Category">
|
||||
|
@ -38,7 +36,6 @@
|
|||
<record id="view_module_filter" model="ir.ui.view">
|
||||
<field name="name">ir.module.module.list.select</field>
|
||||
<field name="model">ir.module.module</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search modules">
|
||||
<field name="name" filter_domain="['|', '|', '|', ('description', 'ilike', self), ('summary', 'ilike', self), ('shortdesc', 'ilike', self), ('name',
|
||||
|
@ -60,7 +57,6 @@
|
|||
<record model="ir.ui.view" id="module_view_kanban">
|
||||
<field name="name">Modules Kanban</field>
|
||||
<field name="model">ir.module.module</field>
|
||||
<field name="type">kanban</field>
|
||||
<field name="arch" type="xml">
|
||||
<kanban create="false">
|
||||
<field name="icon"/>
|
||||
|
@ -69,7 +65,7 @@
|
|||
<field name="summary"/>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div class="oe_module_vignette oe_kanban_auto_height">
|
||||
<div class="oe_module_vignette">
|
||||
<t t-set="installed" t-value="record.state.raw_value == 'installed'"/>
|
||||
<img t-attf-src="#{record.icon.value}" class="oe_module_icon"/>
|
||||
<div class="oe_module_desc">
|
||||
|
@ -108,7 +104,6 @@
|
|||
<record id="module_form" model="ir.ui.view">
|
||||
<field name="name">ir.module.module.form</field>
|
||||
<field name="model">ir.module.module</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Module" version="7.0">
|
||||
<sheet>
|
||||
|
@ -170,7 +165,6 @@
|
|||
<record id="module_tree" model="ir.ui.view">
|
||||
<field name="name">ir.module.module.tree</field>
|
||||
<field name="model">ir.module.module</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree colors="blue:state=='to upgrade' or state=='to install';red:state=='uninstalled';grey:state=='uninstallable';black:state=='installed'" string="Modules">
|
||||
<field name="shortdesc"/>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<record id="wizard_lang_export" model="ir.ui.view">
|
||||
<field name="name">Export Translations</field>
|
||||
<field name="model">base.language.export</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Export Translations" version="7.0">
|
||||
<group colspan="4" states="choose">
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<record id="view_base_import_language" model="ir.ui.view">
|
||||
<field name="name">Import Translation</field>
|
||||
<field name="model">base.language.import</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Import Translation" version="7.0">
|
||||
<group>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<record id="view_base_language_install" model="ir.ui.view">
|
||||
<field name="name">Load a Translation</field>
|
||||
<field name="model">base.language.install</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Load a Translation" version="7.0">
|
||||
<field name="state" invisible="1"/>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<record id="view_base_module_configuration_form" model="ir.ui.view">
|
||||
<field name="name">Module Configuration</field>
|
||||
<field name="model">base.module.configuration</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="System Configuration Done" version="7.0">
|
||||
<label string="All pending configuration wizards have been executed. You may restart individual wizards via the list of configuration wizards."/>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<record id="view_base_module_import" model="ir.ui.view">
|
||||
<field name="name">Module Import</field>
|
||||
<field name="model">base.module.import</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Import module" version="7.0">
|
||||
<field name="state" invisible="1"/>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<record id="view_base_module_scan" model="ir.ui.view">
|
||||
<field name="name">Module Scan</field>
|
||||
<field name="model">base.module.scan</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Scan for new modules" version="7.0">
|
||||
<label string="This function will check if you installed new modules in the 'addons' path of your server installation."/>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<record id="view_base_module_update" model="ir.ui.view">
|
||||
<field name="name">Module Update</field>
|
||||
<field name="model">base.module.update</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Update Module List" version="7.0">
|
||||
<field name="state" invisible="1"/>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<record id="view_base_module_upgrade" model="ir.ui.view">
|
||||
<field name="name">Module Upgrade</field>
|
||||
<field name="model">base.module.upgrade</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="System Update" version="7.0">
|
||||
<div><label string="Your system will be updated."/></div>
|
||||
|
@ -41,7 +40,6 @@
|
|||
<record id="view_base_module_upgrade_install" model="ir.ui.view">
|
||||
<field name="name">Module Upgrade Install</field>
|
||||
<field name="model">base.module.upgrade</field>
|
||||
<field name="type">form</field>
|
||||
<field name="priority" eval="20"/>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Apply Schedule Upgrade" version="7.0">
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
<record id="wizard_update_translations" model="ir.ui.view">
|
||||
<field name="name">Synchronize Terms</field>
|
||||
<field name="model">base.update.translations</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Synchronize Terms" version="7.0">
|
||||
<group string="Synchronize Translation">
|
||||
|
|
|
@ -86,7 +86,7 @@ class publisher_warranty_contract(osv.osv):
|
|||
db_create_date = self.pool.get('ir.config_parameter').get_param(cr, uid, 'database.create_date')
|
||||
user = self.pool.get("res.users").browse(cr, uid, uid)
|
||||
user_name = user.name
|
||||
email = user.user_email
|
||||
email = user.email
|
||||
|
||||
msg = {'contract_name': valid_contract.name,
|
||||
'tb': tb,
|
||||
|
@ -333,7 +333,7 @@ def get_sys_logs(cr, uid):
|
|||
"db_create_date": db_create_date,
|
||||
"version": release.version,
|
||||
"contracts": [c.name for c in contracts],
|
||||
"language": user.context_lang,
|
||||
"language": user.lang,
|
||||
}
|
||||
|
||||
add_arg = {"timeout":30} if sys.version_info >= (2,6) else {}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
<record id="publisher_warranty_contract_tree_view" model="ir.ui.view">
|
||||
<field name="name">publisher_warranty.contract.tree</field>
|
||||
<field name="model">publisher_warranty.contract</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Publisher Warranty Contracts">
|
||||
<field name="name"/>
|
||||
|
@ -21,7 +20,6 @@
|
|||
<record id="publisher_warranty_contract_form_view" model="ir.ui.view">
|
||||
<field name="name">publisher_warranty.contract.form</field>
|
||||
<field name="model">publisher_warranty.contract</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Publisher Warranty Contract" version="7.0">
|
||||
<header>
|
||||
|
@ -55,7 +53,6 @@
|
|||
<record id="publisher_warranty_contract_search_view" model="ir.ui.view">
|
||||
<field name="name">publisher_warranty.contract.search</field>
|
||||
<field name="model">publisher_warranty.contract</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Publisher Warranty Contract">
|
||||
<field name="name" string="Serial Key"/>
|
||||
|
@ -68,7 +65,6 @@
|
|||
<record id="publisher_warranty_contract_view_calendar" model="ir.ui.view">
|
||||
<field name="name">publisher_warranty.contract.calendar</field>
|
||||
<field name="model">publisher_warranty.contract</field>
|
||||
<field name="type">calendar</field>
|
||||
<field name="arch" type="xml">
|
||||
<calendar string="Maintenance Contract" date_start="date_start" color="state">
|
||||
<field name="name"/>
|
||||
|
@ -91,7 +87,6 @@
|
|||
<record id="publisher_warranty_contract_add_wizard" model="ir.ui.view">
|
||||
<field name="name">publisher_warranty.contract.add.wizard</field>
|
||||
<field name="model">publisher_warranty.contract.wizard</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Register a Contract" version="7.0">
|
||||
<field name="state" invisible="1"/>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<record id="ir_property_view_search" model="ir.ui.view">
|
||||
<field name="name">ir.property.search</field>
|
||||
<field name="model">ir.property</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Parameters">
|
||||
<field name="name" string="Name"/>
|
||||
|
@ -21,7 +20,6 @@
|
|||
<record id="ir_property_view" model="ir.ui.view">
|
||||
<field name="name">ir.property.form</field>
|
||||
<field name="model">ir.property</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Parameters" version="7.0">
|
||||
<sheet>
|
||||
|
@ -46,7 +44,6 @@
|
|||
<record id="ir_property_view_tree" model="ir.ui.view">
|
||||
<field name="name">ir.property.tree</field>
|
||||
<field name="model">ir.property</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Parameters">
|
||||
<field name="name"/>
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.6 KiB |
|
@ -139,6 +139,7 @@ class res_partner_bank(osv.osv):
|
|||
'state': fields.selection(_bank_type_get, 'Bank Account Type', required=True,
|
||||
change_default=True),
|
||||
'sequence': fields.integer('Sequence'),
|
||||
'footer': fields.boolean("Display on Reports", help="Display this bank account on the footer of printed documents like invoices and sales orders.")
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
|
@ -211,6 +212,7 @@ class res_partner_bank(osv.osv):
|
|||
if c.partner_id:
|
||||
r = self.onchange_partner_id(cr, uid, ids, c.partner_id.id, context=context)
|
||||
r['value']['partner_id'] = c.partner_id.id
|
||||
r['value']['footer'] = 1
|
||||
result = r
|
||||
return result
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<record id="view_res_bank_form" model="ir.ui.view">
|
||||
<field name="name">res.bank.form</field>
|
||||
<field name="model">res.bank</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Bank" version="7.0">
|
||||
<sheet>
|
||||
|
@ -41,7 +40,6 @@
|
|||
<record id="view_res_bank_tree" model="ir.ui.view">
|
||||
<field name="name">res.bank.tree</field>
|
||||
<field name="model">res.bank</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Banks">
|
||||
<field name="name"/>
|
||||
|
@ -63,7 +61,6 @@
|
|||
<record id="view_partner_bank_type_form" model="ir.ui.view">
|
||||
<field name="name">res.partner.bank.type.form</field>
|
||||
<field name="model">res.partner.bank.type</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Bank Account Type" version="7.0">
|
||||
<group col="4">
|
||||
|
@ -78,7 +75,6 @@
|
|||
<record id="view_partner_bank_type_tree" model="ir.ui.view">
|
||||
<field name="name">res.partner.bank.type.tree</field>
|
||||
<field name="model">res.partner.bank.type</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Bank Account Type">
|
||||
<field name="name"/>
|
||||
|
@ -90,13 +86,13 @@
|
|||
<record id="view_partner_bank_form" model="ir.ui.view">
|
||||
<field name="name">res.partner.bank.form</field>
|
||||
<field name="model">res.partner.bank</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Bank account" version="7.0">
|
||||
<group col="4">
|
||||
<field name="state"/>
|
||||
<field name="acc_number"/>
|
||||
<field name="company_id" on_change="onchange_company_id(company_id)" invisible="context.get('company_hide', True)" widget="selection"/>
|
||||
<field name="footer" attrs="{'invisible': [('company_id','=',False)]}"/>
|
||||
</group>
|
||||
<group>
|
||||
<group name="owner" string="Bank Account Owner">
|
||||
|
@ -109,8 +105,8 @@
|
|||
<field name="zip" class="oe_inline" placeholder="ZIP"/>
|
||||
<field name="city" class="oe_inline" placeholder="City"/>
|
||||
</div>
|
||||
<field name="state_id" placeholder="State"/>
|
||||
<field name="country_id" placeholder="Country"/>
|
||||
<field name="state_id" placeholder="State" options='{"no_open": true}'/>
|
||||
<field name="country_id" placeholder="Country" options='{"no_open": true}'/>
|
||||
</div>
|
||||
</group>
|
||||
<group name="bank" string="Information About the Bank">
|
||||
|
@ -126,13 +122,13 @@
|
|||
<record id="view_partner_bank_tree" model="ir.ui.view">
|
||||
<field name="name">res.partner.bank.tree</field>
|
||||
<field name="model">res.partner.bank</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Bank Accounts">
|
||||
<field name="sequence" invisible="1"/>
|
||||
<field name="acc_number"/>
|
||||
<field name="bank_name"/>
|
||||
<field name="company_id" invisible="context.get('company_hide', True)"/>
|
||||
<field name="footer" invisible="context.get('company_hide', True)"/>
|
||||
<field name="partner_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
@ -140,7 +136,6 @@
|
|||
<record id="view_partner_bank_search" model="ir.ui.view">
|
||||
<field name="name">res.partner.bank.search</field>
|
||||
<field name="model">res.partner.bank</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Bank Accounts">
|
||||
<field name="bank_name" filter_domain="['|', ('bank_name','ilike',self), ('acc_number','ilike',self)]" string="Bank Name"/>
|
||||
|
@ -155,7 +150,7 @@
|
|||
<field name="res_model">res.partner.bank</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="help">Configure your company's bank accounts. You can reorder bank accounts from the list view. If you use the accounting application of OpenERP, journals and accounts will be created automatically based on these data.</field>
|
||||
<field name="help">Configure your company's bank accounts and select those that must appear on the report footer. You can reorder bank accounts from the list view. If you use the accounting application of OpenERP, journals and accounts will be created automatically based on these data.</field>
|
||||
</record>
|
||||
<menuitem action="action_res_partner_bank_account_form"
|
||||
id="menu_action_res_partner_bank_form"
|
||||
|
|
|
@ -142,7 +142,7 @@ class res_company(osv.osv):
|
|||
if phone: val.append(_('Phone: ')+phone)
|
||||
if fax: val.append(_('Fax: ')+fax)
|
||||
if website: val.append(_('Website: ')+website)
|
||||
if vat: val.append(_('VAT: ')+vat)
|
||||
if vat: val.append(_('TIN: ')+vat)
|
||||
if reg: val.append(_('Reg: ')+reg)
|
||||
return {'value': {'rml_footer1':' | '.join(val)}}
|
||||
|
||||
|
@ -154,11 +154,9 @@ class res_company(osv.osv):
|
|||
|
||||
def _search(self, cr, uid, args, offset=0, limit=None, order=None,
|
||||
context=None, count=False, access_rights_uid=None):
|
||||
|
||||
if context is None:
|
||||
context = {}
|
||||
user_preference = context.get('user_preference', False)
|
||||
if user_preference:
|
||||
if context.get('user_preference'):
|
||||
# We browse as superuser. Otherwise, the user would be able to
|
||||
# select only the currently visible companies (according to rules,
|
||||
# which are probably to allow to see the child companies) even if
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
<record id="view_company_form" model="ir.ui.view">
|
||||
<field name="name">res.company.form</field>
|
||||
<field name="model">res.company</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Company" version="7.0">
|
||||
<sheet>
|
||||
|
@ -51,10 +50,10 @@
|
|||
<field name="street2"/>
|
||||
<div>
|
||||
<field name="city" placeholder="City" style="width: 40%%"/>
|
||||
<field name="state_id" class="oe_no_button" placeholder="State" style="width: 24%%"/>
|
||||
<field name="state_id" class="oe_no_button" placeholder="State" style="width: 24%%" options='{"no_open": true}'/>
|
||||
<field name="zip" placeholder="ZIP" style="width: 34%%"/>
|
||||
</div>
|
||||
<field name="country_id" placeholder="Country" class="oe_no_button" on_change="on_change_country(country_id)"/>
|
||||
<field name="country_id" placeholder="Country" class="oe_no_button" options='{"no_open": true}' on_change="on_change_country(country_id)"/>
|
||||
</div>
|
||||
<field name="website" widget="url" placeholder="e.g. www.openerp.com"/>
|
||||
</group>
|
||||
|
@ -102,7 +101,6 @@
|
|||
<record id="view_company_tree" model="ir.ui.view">
|
||||
<field name="name">res.company.tree</field>
|
||||
<field name="model">res.company</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="field_parent">child_ids</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Companies">
|
||||
|
@ -131,7 +129,6 @@
|
|||
<record id="view_inventory_tree" model="ir.ui.view">
|
||||
<field name="name">multi_company.default.tree</field>
|
||||
<field name="model">multi_company.default</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="priority" eval="8"/>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Multi Company">
|
||||
|
@ -148,7 +145,6 @@
|
|||
<record id="view_inventory_form" model="ir.ui.view">
|
||||
<field name="name">multi_company.default.form</field>
|
||||
<field name="model">multi_company.default</field>
|
||||
<field name="type">form</field>
|
||||
<field name="priority" eval="8"/>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Multi Company" version="7.0">
|
||||
|
@ -173,7 +169,6 @@
|
|||
<record id="view_inventory_search" model="ir.ui.view">
|
||||
<field name="name">multi_company.default.search</field>
|
||||
<field name="model">multi_company.default</field>
|
||||
<field name="type">search</field>
|
||||
<field name="priority" eval="8"/>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Multi Company">
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="res_config_view_base" model="ir.ui.view">
|
||||
<field name="name">res.config.view.base</field>
|
||||
<field name="model">res.config</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form version="7.0">
|
||||
<form string="Configuration" version="7.0">
|
||||
<group string="res_config_contents"/>
|
||||
<footer>
|
||||
<button name="action_next" type="object" string="Apply" class="oe_highlight"/>
|
||||
|
@ -21,7 +19,6 @@
|
|||
<record id="view_config_wizard_form" model="ir.ui.view">
|
||||
<field name="name">Compabitiliby configuration wizard</field>
|
||||
<field name="model">ir.actions.configuration.wizard</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Next Configuration Step" version="7.0">
|
||||
<group>
|
||||
|
@ -39,9 +36,8 @@
|
|||
<record id="res_config_installer" model="ir.ui.view">
|
||||
<field name="name">Inheritable view for installer objects</field>
|
||||
<field name="model">res.config.installer</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form version="7.0">
|
||||
<form string="Configuration Installer" version="7.0">
|
||||
<separator string="title" colspan="4"/>
|
||||
<footer>
|
||||
<button name="action_next" type="object" string="Install Modules" class="oe_highlight"/>
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
<record id="view_country_tree" model="ir.ui.view">
|
||||
<field name="name">res.country.tree</field>
|
||||
<field name="model">res.country</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Country">
|
||||
<field name="name"/>
|
||||
|
@ -21,7 +20,6 @@
|
|||
<record id="view_country_form" model="ir.ui.view">
|
||||
<field name="name">res.country.form</field>
|
||||
<field name="model">res.country</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Country" version="7.0">
|
||||
<group>
|
||||
|
@ -58,7 +56,6 @@
|
|||
<record id="view_country_state_tree" model="ir.ui.view">
|
||||
<field name="name">res.country.state.tree</field>
|
||||
<field name="model">res.country.state</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="State">
|
||||
<field name="name"/>
|
||||
|
@ -71,13 +68,12 @@
|
|||
<record id="view_country_state_form" model="ir.ui.view">
|
||||
<field name="name">res.country.state.form</field>
|
||||
<field name="model">res.country.state</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="State" version="7.0">
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
<field name="country_id"/>
|
||||
<field name="country_id" options='{"no_open": true}'/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<record id="view_currency_search" model="ir.ui.view">
|
||||
<field name="name">res.currency.search</field>
|
||||
<field name="model">res.currency</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Currencies">
|
||||
<field name="name" string="Currency"/>
|
||||
|
@ -17,7 +16,6 @@
|
|||
<record id="view_currency_tree" model="ir.ui.view">
|
||||
<field name="name">res.currency.tree</field>
|
||||
<field name="model">res.currency</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Currencies">
|
||||
<field name="name"/>
|
||||
|
@ -35,7 +33,6 @@
|
|||
<record id="view_currency_form" model="ir.ui.view">
|
||||
<field name="name">res.currency.form</field>
|
||||
<field name="model">res.currency</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Currency" version="7.0">
|
||||
<group col="4">
|
||||
|
@ -86,7 +83,6 @@
|
|||
<record id="view_currency_rate_type_form" model="ir.ui.view">
|
||||
<field name="name">res.currency.rate.type.form</field>
|
||||
<field name="model">res.currency.rate.type</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Currency Rate Type" version="7.0">
|
||||
<group>
|
||||
|
@ -106,7 +102,6 @@
|
|||
<record id="view_currency_rate_type_search" model="ir.ui.view">
|
||||
<field name="name">res.currency.rate.type.search</field>
|
||||
<field name="model">res.currency.rate.type</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Currency Rate Type">
|
||||
<field name="name" string="Name"/>
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
<record id="res_lang_tree" model="ir.ui.view">
|
||||
<field name="name">res.lang.tree</field>
|
||||
<field name="model">res.lang</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Languages">
|
||||
<field name="name"/>
|
||||
|
@ -21,7 +20,6 @@
|
|||
<record id="res_lang_form" model="ir.ui.view">
|
||||
<field name="name">res.lang.form</field>
|
||||
<field name="model">res.lang</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Languages" version="7.0">
|
||||
<sheet>
|
||||
|
@ -105,7 +103,6 @@
|
|||
<record id="res_lang_search" model="ir.ui.view">
|
||||
<field name="name">res.lang.search</field>
|
||||
<field name="model">res.lang</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Languages">
|
||||
<field name="name"
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
##############################################################################
|
||||
|
||||
import math
|
||||
import openerp
|
||||
import os
|
||||
from osv import osv, fields
|
||||
import re
|
||||
|
@ -27,6 +28,10 @@ import tools
|
|||
from tools.translate import _
|
||||
import logging
|
||||
import pooler
|
||||
import pytz
|
||||
|
||||
def _tz_get(self,cr,uid, context=None):
|
||||
return [(x, x) for x in pytz.all_timezones]
|
||||
|
||||
class res_payterm(osv.osv):
|
||||
_description = 'Payment term'
|
||||
|
@ -150,9 +155,14 @@ class res_partner(osv.osv):
|
|||
'parent_id': fields.many2one('res.partner', 'Owned by'),
|
||||
'child_ids': fields.one2many('res.partner', 'parent_id', 'Contacts'),
|
||||
'ref': fields.char('Reference', size=64, select=1),
|
||||
'lang': fields.selection(_lang_get, 'Language', help="If the selected language is loaded in the system, all documents related to this partner will be printed in this language. If not, it will be english."),
|
||||
'lang': fields.selection(_lang_get, 'Language',
|
||||
help="If the selected language is loaded in the system, all documents related to this partner will be printed in this language. If not, it will be english."),
|
||||
'tz': fields.selection(_tz_get, 'Timezone', size=64,
|
||||
help="The partner's timezone, used to output proper date and time values inside printed reports. "
|
||||
"It is important to set a value for this field. You should use the same timezone "
|
||||
"that is otherwise used to pick and render date and time values: your computer's timezone."),
|
||||
'user_id': fields.many2one('res.users', 'Salesperson', help='The internal user that is in charge of communicating with this partner if any.'),
|
||||
'vat': fields.char('VAT',size=32 ,help="Value Added Tax number. Check the box if the partner is subjected to the VAT. Used by the VAT legal statement."),
|
||||
'vat': fields.char('TIN',size=32 ,help="Tax Identification Number. Check the box if the partner is subjected to taxes. Used by the some of the legal statements."),
|
||||
'bank_ids': fields.one2many('res.partner.bank', 'partner_id', 'Banks'),
|
||||
'website': fields.char('Website',size=64, help="Website of Partner or Company"),
|
||||
'comment': fields.text('Notes'),
|
||||
|
@ -165,10 +175,10 @@ class res_partner(osv.osv):
|
|||
'supplier': fields.boolean('Supplier', help="Check this box if the partner is a supplier. If it's not checked, purchase people will not see it when encoding a purchase order."),
|
||||
'employee': fields.boolean('Employee', help="Check this box if the partner is an Employee."),
|
||||
'function': fields.char('Job Position', size=128),
|
||||
'type': fields.selection( [('default','Default'),('invoice','Invoice'),
|
||||
'type': fields.selection( [('default','Default'), ('invoice','Invoice'),
|
||||
('delivery','Delivery'), ('contact','Contact'),
|
||||
('other','Other')],
|
||||
'Address Type', help="Used to select automatically the right address according to the context in sales and purchases documents."),
|
||||
('other', 'Other')], 'Address Type',
|
||||
help="Used to select automatically the right address according to the context in sales and purchases documents."),
|
||||
'street': fields.char('Street', size=128),
|
||||
'street2': fields.char('Street2', size=128),
|
||||
'zip': fields.char('Zip', change_default=True, size=24),
|
||||
|
@ -217,13 +227,15 @@ class res_partner(osv.osv):
|
|||
|
||||
def _get_default_image(self, cr, uid, is_company, context=None):
|
||||
if is_company:
|
||||
image_path = os.path.join( tools.config['root_path'], 'addons', 'base', 'res', 'company_icon.png')
|
||||
image_path = openerp.modules.get_module_resource('base', 'static/src/img', 'company_image.png')
|
||||
else:
|
||||
image_path = os.path.join( tools.config['root_path'], 'addons', 'base', 'res', 'photo.png')
|
||||
image_path = openerp.modules.get_module_resource('base', 'static/src/img', 'partner_image.png')
|
||||
return tools.image_resize_image_big(open(image_path, 'rb').read().encode('base64'))
|
||||
|
||||
_defaults = {
|
||||
'active': True,
|
||||
'lang': lambda self, cr, uid, context: context.get('lang', 'en_US'),
|
||||
'tz': lambda self, cr, uid, context: context.get('tz', False),
|
||||
'customer': True,
|
||||
'category_id': _default_category,
|
||||
'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'res.partner', context=c),
|
||||
|
@ -232,6 +244,8 @@ class res_partner(osv.osv):
|
|||
'type': 'default',
|
||||
'use_parent_address': True,
|
||||
'image': lambda self, cr, uid, context: self._get_default_image(cr, uid, False, context),
|
||||
'image_small': lambda self, cr, uid, context: self._get_default_image(cr, uid, False, context),
|
||||
'image_medium': lambda self, cr, uid, context: self._get_default_image(cr, uid, False, context),
|
||||
}
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
|
@ -316,7 +330,8 @@ class res_partner(osv.osv):
|
|||
|
||||
def update_address(self, cr, uid, ids, vals, context=None):
|
||||
addr_vals = dict((key, vals[key]) for key in POSTAL_ADDRESS_FIELDS if vals.get(key))
|
||||
return super(res_partner, self).write(cr, uid, ids, addr_vals, context)
|
||||
if addr_vals:
|
||||
return super(res_partner, self).write(cr, uid, ids, addr_vals, context)
|
||||
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -16,7 +16,6 @@
|
|||
<record id="view_partner_title_tree" model="ir.ui.view">
|
||||
<field name="name">res.partner.title.tree</field>
|
||||
<field name="model">res.partner.title</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Partner Titles">
|
||||
<field name="name"/>
|
||||
|
@ -27,7 +26,6 @@
|
|||
<record id="view_partner_title_form" model="ir.ui.view">
|
||||
<field name="name">res.partner.title.form</field>
|
||||
<field name="model">res.partner.title</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Partner Titles" version="7.0">
|
||||
<group col="4">
|
||||
|
@ -76,7 +74,6 @@
|
|||
<record id="view_partner_tree" model="ir.ui.view">
|
||||
<field name="name">res.partner.tree</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="type">tree</field>
|
||||
<field eval="8" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Contacts">
|
||||
|
@ -95,11 +92,10 @@
|
|||
<record id="view_partner_form" model="ir.ui.view">
|
||||
<field name="name">res.partner.form</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Partners" version="7.0">
|
||||
<sheet>
|
||||
<field name="image_small" widget='image' class="oe_avatar oe_left"/>
|
||||
<field name="image_medium" widget='image' class="oe_avatar oe_left"/>
|
||||
<div class="oe_title">
|
||||
<div class="oe_edit_only">
|
||||
<label for="name"/> (
|
||||
|
@ -119,8 +115,8 @@
|
|||
|
||||
<group>
|
||||
<group>
|
||||
<label for="type" attrs="{'invisible': [('parent_id','=', False)]}"/>
|
||||
<div attrs="{'invisible': [('parent_id','=', False)]}">
|
||||
<label for="type" attrs="{'invisible': [('parent_id','=', False)]}" invisible="1"/>
|
||||
<div attrs="{'invisible': [('parent_id','=', False)]}" invisible="1" name="div_type">
|
||||
<field class="oe_inline"
|
||||
name="type"/>
|
||||
<label for="use_parent_address" class="oe_edit_only"/>
|
||||
|
@ -134,10 +130,10 @@
|
|||
<field name="street2"/>
|
||||
<div class="address_format">
|
||||
<field name="city" placeholder="City" style="width: 40%%"/>
|
||||
<field name="state_id" options='{"no_open": true}' placeholder="State" style="width: 24%%"/>
|
||||
<field name="state_id" class="oe_no_button" placeholder="State" style="width: 24%%" options='{"no_open": true}'/>
|
||||
<field name="zip" placeholder="ZIP" style="width: 34%%"/>
|
||||
</div>
|
||||
<field name="country_id" placeholder="Country" options='{"no_open": true}'/>
|
||||
<field name="country_id" placeholder="Country" class="oe_no_button" options='{"no_open": true}'/>
|
||||
</div>
|
||||
<field name="website" widget="url" placeholder="e.g. www.openerp.com"/>
|
||||
</group>
|
||||
|
@ -228,7 +224,7 @@
|
|||
<page string="Sales & Purchases" attrs="{'invisible': [('customer', '=', False), ('supplier', '=', False)]}">
|
||||
<group>
|
||||
<group>
|
||||
<field name="user_id" />
|
||||
<field name="user_id"/>
|
||||
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
|
||||
</group>
|
||||
<group>
|
||||
|
@ -257,7 +253,6 @@
|
|||
<record id="view_res_partner_filter" model="ir.ui.view">
|
||||
<field name="name">res.partner.select</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Partner">
|
||||
<field name="name"
|
||||
|
@ -286,7 +281,6 @@
|
|||
<record model="ir.ui.view" id="res_partner_kanban_view">
|
||||
<field name="name">res.partner.kanban</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="type">kanban</field>
|
||||
<field name="arch" type="xml">
|
||||
<kanban>
|
||||
<field name="color"/>
|
||||
|
@ -436,7 +430,6 @@
|
|||
<record id="view_payterm_form" model="ir.ui.view">
|
||||
<field name="name">res.payterm</field>
|
||||
<field name="model">res.payterm</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Payment Term" version="7.0">
|
||||
<group>
|
||||
|
@ -457,7 +450,6 @@
|
|||
<record id="view_partner_category_form" model="ir.ui.view">
|
||||
<field name="name">Partner Categories</field>
|
||||
<field name="model">res.partner.category</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Partner Category" version="7.0">
|
||||
<group col="4">
|
||||
|
@ -471,7 +463,6 @@
|
|||
<record id="view_partner_category_list" model="ir.ui.view">
|
||||
<field name="name">Partner Categories</field>
|
||||
<field name="model">res.partner.category</field>
|
||||
<field name="type">tree</field>
|
||||
<field eval="6" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Partner Categories">
|
||||
|
@ -482,7 +473,6 @@
|
|||
<record id="view_partner_category_tree" model="ir.ui.view">
|
||||
<field name="name">res.partner.category.tree</field>
|
||||
<field name="model">res.partner.category</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="field_parent">child_ids</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree toolbar="1" string="Partner Categories">
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
<record id="res_request_link-view" model="ir.ui.view">
|
||||
<field name="name">res.request.link.form</field>
|
||||
<field name="model">res.request.link</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Request Link" version="7.0">
|
||||
<sheet>
|
||||
|
@ -20,7 +19,6 @@
|
|||
<record id="res_request_link_tree-view" model="ir.ui.view">
|
||||
<field name="name">res.request.link.form</field>
|
||||
<field name="model">res.request.link</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Request Link">
|
||||
<field name="name"/>
|
||||
|
@ -31,7 +29,6 @@
|
|||
<record id="res_request_link_search_view" model="ir.ui.view">
|
||||
<field name="name">res.request.link.search</field>
|
||||
<field name="model">res.request.link</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Request Link">
|
||||
<field name="name" filter_domain="['|', ('name','ilike',self), ('object','ilike',self)]" string="Subject"/>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
# Copyright (C) 2010-2011 OpenERP s.a. (<http://openerp.com>).
|
||||
# Copyright (C) 2010-2012 OpenERP s.a. (<http://openerp.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
|
@ -20,11 +20,9 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import logging
|
||||
|
||||
from functools import partial
|
||||
|
||||
import pytz
|
||||
|
||||
import logging
|
||||
from lxml import etree
|
||||
from lxml.builder import E
|
||||
import netsvc
|
||||
|
@ -96,59 +94,22 @@ class groups(osv.osv):
|
|||
|
||||
groups()
|
||||
|
||||
def _lang_get(self, cr, uid, context=None):
|
||||
obj = self.pool.get('res.lang')
|
||||
ids = obj.search(cr, uid, [('translatable','=',True)])
|
||||
res = obj.read(cr, uid, ids, ['code', 'name'], context=context)
|
||||
res = [(r['code'], r['name']) for r in res]
|
||||
return res
|
||||
class res_users(osv.osv):
|
||||
""" User class. A res.users record models an OpenERP user and is different
|
||||
from an employee.
|
||||
|
||||
def _tz_get(self,cr,uid, context=None):
|
||||
return [(x, x) for x in pytz.all_timezones]
|
||||
|
||||
class users(osv.osv):
|
||||
res.users class now inherits from res.partner. The partner model is
|
||||
used to store the data related to the partner: lang, name, address,
|
||||
avatar, ... The user model is now dedicated to technical data.
|
||||
"""
|
||||
__admin_ids = {}
|
||||
_uid_cache = {}
|
||||
_inherits = {
|
||||
'res.partner': 'partner_id',
|
||||
}
|
||||
_name = "res.users"
|
||||
_description = 'Users'
|
||||
_order = 'name'
|
||||
|
||||
WELCOME_MAIL_SUBJECT = u"Welcome to OpenERP"
|
||||
WELCOME_MAIL_BODY = u"An OpenERP account has been created for you, "\
|
||||
"\"%(name)s\".\n\nYour login is %(login)s, "\
|
||||
"you should ask your supervisor or system administrator if you "\
|
||||
"haven't been given your password yet.\n\n"\
|
||||
"If you aren't %(name)s, this email reached you errorneously, "\
|
||||
"please delete it."
|
||||
|
||||
def get_welcome_mail_subject(self, cr, uid, context=None):
|
||||
""" Returns the subject of the mail new users receive (when
|
||||
created via the res.config.users wizard), default implementation
|
||||
is to return config_users.WELCOME_MAIL_SUBJECT
|
||||
"""
|
||||
return self.WELCOME_MAIL_SUBJECT
|
||||
def get_welcome_mail_body(self, cr, uid, context=None):
|
||||
""" Returns the subject of the mail new users receive (when
|
||||
created via the res.config.users wizard), default implementation
|
||||
is to return config_users.WELCOME_MAIL_BODY
|
||||
"""
|
||||
return self.WELCOME_MAIL_BODY
|
||||
|
||||
def get_current_company(self, cr, uid):
|
||||
cr.execute('select company_id, res_company.name from res_users left join res_company on res_company.id = company_id where res_users.id=%s' %uid)
|
||||
return cr.fetchall()
|
||||
|
||||
def send_welcome_email(self, cr, uid, id, context=None):
|
||||
if isinstance(id,list): id = id[0]
|
||||
user = self.read(cr, uid, id, ['email','login','name', 'user_email'], context=context)
|
||||
email = user['email'] or user['user_email']
|
||||
|
||||
ir_mail_server = self.pool.get('ir.mail_server')
|
||||
msg = ir_mail_server.build_email(email_from=None, # take config default
|
||||
email_to=[email],
|
||||
subject=self.get_welcome_mail_subject(cr, uid, context=context),
|
||||
body=(self.get_welcome_mail_body(cr, uid, context=context) % user))
|
||||
return ir_mail_server.send_email(cr, uid, msg, context=context)
|
||||
_order = 'login'
|
||||
|
||||
def _set_new_password(self, cr, uid, id, name, value, args, context=None):
|
||||
if value is False:
|
||||
|
@ -164,85 +125,67 @@ class users(osv.osv):
|
|||
|
||||
def _get_password(self, cr, uid, ids, arg, karg, context=None):
|
||||
return dict.fromkeys(ids, '')
|
||||
|
||||
def _get_image(self, cr, uid, ids, name, args, context=None):
|
||||
result = dict.fromkeys(ids, False)
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
result[obj.id] = tools.image_get_resized_images(obj.image)
|
||||
return result
|
||||
|
||||
def _set_image(self, cr, uid, id, name, value, args, context=None):
|
||||
return self.write(cr, uid, [id], {'image': tools.image_resize_image_big(value)}, context=context)
|
||||
|
||||
_columns = {
|
||||
'id': fields.integer('ID'),
|
||||
'name': fields.char('User Name', size=64, required=True, select=True,
|
||||
help="The new user's real name, used for searching"
|
||||
" and most listings"),
|
||||
'login_date': fields.date('Latest connection', select=1),
|
||||
'partner_id': fields.many2one('res.partner', required=True,
|
||||
string='Related Partner', ondelete='cascade',
|
||||
help='Partner-related data of the user'),
|
||||
'login': fields.char('Login', size=64, required=True,
|
||||
help="Used to log into the system"),
|
||||
'password': fields.char('Password', size=64, invisible=True, help="Keep empty if you don't want the user to be able to connect on the system."),
|
||||
help="Used to log into the system"),
|
||||
'password': fields.char('Password', size=64, invisible=True,
|
||||
help="Keep empty if you don't want the user to be able to connect on the system."),
|
||||
'new_password': fields.function(_get_password, type='char', size=64,
|
||||
fnct_inv=_set_new_password,
|
||||
string='Set Password', help="Specify a value only when creating a user or if you're changing the user's password, "
|
||||
"otherwise leave empty. After a change of password, the user has to login again."),
|
||||
'user_email': fields.char('Email', size=64),
|
||||
fnct_inv=_set_new_password, string='Set Password',
|
||||
help="Specify a value only when creating a user or if you're "\
|
||||
"changing the user's password, otherwise leave empty. After "\
|
||||
"a change of password, the user has to login again."),
|
||||
'signature': fields.text('Signature', size=64),
|
||||
'image': fields.binary("Avatar",
|
||||
help="This field holds the image used as avatar for the "\
|
||||
"user. The image is base64 encoded, and PIL-supported. "\
|
||||
"It is limited to a 1024x1024 px image."),
|
||||
'image_medium': fields.function(_get_image, fnct_inv=_set_image,
|
||||
string="Medium-sized avatar", type="binary", multi="_get_image",
|
||||
store = {
|
||||
'res.users': (lambda self, cr, uid, ids, c={}: ids, ['image'], 10),
|
||||
},
|
||||
help="Medium-sized image of the user. It is automatically "\
|
||||
"resized as a 180x180 px image, with aspect ratio preserved. "\
|
||||
"Use this field in form views or some kanban views."),
|
||||
'image_small': fields.function(_get_image, fnct_inv=_set_image,
|
||||
string="Smal-sized avatar", type="binary", multi="_get_image",
|
||||
store = {
|
||||
'res.users': (lambda self, cr, uid, ids, c={}: ids, ['image'], 10),
|
||||
},
|
||||
help="Small-sized image of the user. It is automatically "\
|
||||
"resized as a 50x50 px image, with aspect ratio preserved. "\
|
||||
"Use this field anywhere a small image is required."),
|
||||
'active': fields.boolean('Active'),
|
||||
'action_id': fields.many2one('ir.actions.actions', 'Home Action', help="If specified, this action will be opened at logon for this user, in addition to the standard menu."),
|
||||
'menu_id': fields.many2one('ir.actions.actions', 'Menu Action', help="If specified, the action will replace the standard menu for this user."),
|
||||
'groups_id': fields.many2many('res.groups', 'res_groups_users_rel', 'uid', 'gid', 'Groups'),
|
||||
|
||||
# Special behavior for this field: res.company.search() will only return the companies
|
||||
# available to the current user (should be the user's companies?), when the user_preference
|
||||
# context is set.
|
||||
'company_id': fields.many2one('res.company', 'Company', required=True,
|
||||
help="The company this user is currently working for.", context={'user_preference': True}),
|
||||
|
||||
help='The company this user is currently working for.', context={'user_preference': True}),
|
||||
'company_ids':fields.many2many('res.company','res_company_users_rel','user_id','cid','Companies'),
|
||||
'context_lang': fields.selection(_lang_get, 'Language', required=True,
|
||||
help="The default language used in the graphical user interface, when translations are available. To add a new language, you can use the 'Load a Translation' wizard available from the 'Administration' menu."),
|
||||
'context_tz': fields.selection(_tz_get, 'Timezone', size=64,
|
||||
help="The user's timezone, used to output proper date and time values inside printed reports. "
|
||||
"It is important to set a value for this field. You should use the same timezone "
|
||||
"that is otherwise used to pick and render date and time values: your computer's timezone."),
|
||||
'date': fields.datetime('Latest Connection', readonly=True),
|
||||
# backward compatibility fields
|
||||
'user_email': fields.related('email', type='char',
|
||||
deprecated='Use the email field instead of user_email. This field will be removed with OpenERP 7.1.'),
|
||||
}
|
||||
|
||||
def on_change_company_id(self, cr, uid, ids, company_id):
|
||||
return {
|
||||
'warning' : {
|
||||
return {'warning' : {
|
||||
'title': _("Company Switch Warning"),
|
||||
'message': _("Please keep in mind that documents currently displayed may not be relevant after switching to another company. If you have unsaved changes, please make sure to save and close all forms before switching to a different company. (You can click on Cancel in the User Preferences now)"),
|
||||
}
|
||||
}
|
||||
|
||||
def onchange_type(self, cr, uid, ids, is_company, context=None):
|
||||
""" Wrapper on the user.partner onchange_type, because some calls to the
|
||||
partner form view applied to the user may trigger the
|
||||
partner.onchange_type method, but applied to the user object.
|
||||
"""
|
||||
partner_ids = [user.partner_id.id for user in self.browse(cr, uid, ids, context=context)]
|
||||
return self.pool.get('res.partner').onchange_type(cr, uid, partner_ids, is_company, context=context)
|
||||
|
||||
def onchange_address(self, cr, uid, ids, use_parent_address, parent_id, context=None):
|
||||
""" Wrapper on the user.partner onchange_address, because some calls to the
|
||||
partner form view applied to the user may trigger the
|
||||
partner.onchange_type method, but applied to the user object.
|
||||
"""
|
||||
partner_ids = [user.partner_id.id for user in self.browse(cr, uid, ids, context=context)]
|
||||
return self.pool.get('res.partner').onchange_address(cr, uid, partner_ids, use_parent_address, parent_id, context=context)
|
||||
|
||||
def read(self,cr, uid, ids, fields=None, context=None, load='_classic_read'):
|
||||
def override_password(o):
|
||||
if 'password' in o and ( 'id' not in o or o['id'] != uid ):
|
||||
o['password'] = '********'
|
||||
return o
|
||||
result = super(users, self).read(cr, uid, ids, fields, context, load)
|
||||
result = super(res_users, self).read(cr, uid, ids, fields, context, load)
|
||||
canwrite = self.pool.get('ir.model.access').check(cr, uid, 'res.users', 'write', False)
|
||||
if not canwrite:
|
||||
if isinstance(ids, (int, float)):
|
||||
|
@ -263,21 +206,10 @@ class users(osv.osv):
|
|||
('login_key', 'UNIQUE (login)', 'You can not have two users with the same login !')
|
||||
]
|
||||
|
||||
def _get_email_from(self, cr, uid, ids, context=None):
|
||||
if not isinstance(ids, list):
|
||||
ids = [ids]
|
||||
res = dict.fromkeys(ids, False)
|
||||
for user in self.browse(cr, uid, ids, context=context):
|
||||
if user.user_email:
|
||||
res[user.id] = "%s <%s>" % (user.name, user.user_email)
|
||||
return res
|
||||
|
||||
def _get_admin_id(self, cr):
|
||||
if self.__admin_ids.get(cr.dbname) is None:
|
||||
ir_model_data_obj = self.pool.get('ir.model.data')
|
||||
mdid = ir_model_data_obj._get_id(cr, 1, 'base', 'user_root')
|
||||
self.__admin_ids[cr.dbname] = ir_model_data_obj.read(cr, 1, [mdid], ['res_id'])[0]['res_id']
|
||||
return self.__admin_ids[cr.dbname]
|
||||
def _get_default_image(self, cr, uid, context=None):
|
||||
""" Override of res.partner: multicolor avatars ! """
|
||||
image_path = openerp.modules.get_module_resource('base', 'static/src/img', 'avatar%d.png' % random.randint(0, 6))
|
||||
return tools.image_resize_image_big(open(image_path, 'rb').read().encode('base64'))
|
||||
|
||||
def _get_company(self,cr, uid, context=None, uid2=False):
|
||||
if not uid2:
|
||||
|
@ -315,25 +247,29 @@ class users(osv.osv):
|
|||
pass
|
||||
return result
|
||||
|
||||
def _get_default_image(self, cr, uid, context=None):
|
||||
# default image file name: avatar0 -> avatar6.png, choose randomly
|
||||
image_path = openerp.modules.get_module_resource('base', 'static/src/img', 'avatar%d.png' % random.randint(0, 6))
|
||||
return tools.image_resize_image_big(open(image_path, 'rb').read().encode('base64'))
|
||||
|
||||
_defaults = {
|
||||
'password' : '',
|
||||
'context_lang': lambda self, cr, uid, context: context.get('lang', 'en_US'),
|
||||
'context_tz': lambda self, cr, uid, context: context.get('tz', False),
|
||||
'image': _get_default_image,
|
||||
'active' : True,
|
||||
'customer': False,
|
||||
'menu_id': _get_menu,
|
||||
'company_id': _get_company,
|
||||
'company_ids': _get_companies,
|
||||
'groups_id': _get_group,
|
||||
'image': lambda self, cr, uid, context: self._get_default_image(cr, uid, context),
|
||||
}
|
||||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
""" Override of res.users fields_view_get.
|
||||
- if the view is specified: resume with normal behavior
|
||||
- else: the default view is overrided and redirected to the partner
|
||||
view
|
||||
"""
|
||||
if not view_id and view_type == 'form':
|
||||
return self.pool.get('res.partner').fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
|
||||
return super(res_users, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
|
||||
|
||||
# User can write to a few of her own fields (but not her groups for example)
|
||||
SELF_WRITEABLE_FIELDS = ['password', 'signature', 'action_id', 'company_id', 'user_email', 'name', 'image', 'image_medium', 'image_small']
|
||||
SELF_WRITEABLE_FIELDS = ['password', 'signature', 'action_id', 'company_id', 'email', 'name', 'image', 'image_medium', 'image_small']
|
||||
|
||||
def write(self, cr, uid, ids, values, context=None):
|
||||
if not hasattr(ids, '__iter__'):
|
||||
|
@ -348,7 +284,7 @@ class users(osv.osv):
|
|||
del values['company_id']
|
||||
uid = 1 # safe fields only, so we write as super-user to bypass access rights
|
||||
|
||||
res = super(users, self).write(cr, uid, ids, values, context=context)
|
||||
res = super(res_users, self).write(cr, uid, ids, values, context=context)
|
||||
|
||||
# clear caches linked to the users
|
||||
self.pool.get('ir.model.access').call_cache_clearing_methods(cr)
|
||||
|
@ -370,7 +306,7 @@ class users(osv.osv):
|
|||
for id in ids:
|
||||
if id in self._uid_cache[db]:
|
||||
del self._uid_cache[db][id]
|
||||
return super(users, self).unlink(cr, uid, ids, context=context)
|
||||
return super(res_users, self).unlink(cr, uid, ids, context=context)
|
||||
|
||||
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100):
|
||||
if not args:
|
||||
|
@ -393,17 +329,23 @@ class users(osv.osv):
|
|||
name=(copy_pattern % user2copy['name']),
|
||||
)
|
||||
copydef.update(default)
|
||||
return super(users, self).copy(cr, uid, id, copydef, context)
|
||||
return super(res_users, self).copy(cr, uid, id, copydef, context)
|
||||
|
||||
def context_get(self, cr, uid, context=None):
|
||||
user = self.browse(cr, uid, uid, context)
|
||||
user = self.browse(cr, 1, uid, context)
|
||||
result = {}
|
||||
for k in self._columns.keys():
|
||||
for k in self._all_columns.keys():
|
||||
if k.startswith('context_'):
|
||||
context_key = k[8:]
|
||||
elif k in ['lang', 'tz']:
|
||||
context_key = k
|
||||
else:
|
||||
context_key = False
|
||||
if context_key:
|
||||
res = getattr(user,k) or False
|
||||
if isinstance(res, browse_record):
|
||||
res = res.id
|
||||
result[k[8:]] = res or False
|
||||
result[context_key] = res or False
|
||||
return result
|
||||
|
||||
def action_get(self, cr, uid, context=None):
|
||||
|
@ -411,6 +353,57 @@ class users(osv.osv):
|
|||
data_id = dataobj._get_id(cr, 1, 'base', 'action_res_users_my')
|
||||
return dataobj.browse(cr, uid, data_id, context=context).res_id
|
||||
|
||||
def check_super(self, passwd):
|
||||
if passwd == tools.config['admin_passwd']:
|
||||
return True
|
||||
else:
|
||||
raise openerp.exceptions.AccessDenied()
|
||||
|
||||
def check_credentials(self, cr, uid, password):
|
||||
""" Override this method to plug additional authentication methods"""
|
||||
res = self.search(cr, 1, [('id','=',uid),('password','=',password)])
|
||||
if not res:
|
||||
raise openerp.exceptions.AccessDenied()
|
||||
|
||||
def login(self, db, login, password):
|
||||
if not password:
|
||||
return False
|
||||
user_id = False
|
||||
cr = pooler.get_db(db).cursor()
|
||||
try:
|
||||
# autocommit: our single update request will be performed atomically.
|
||||
# (In this way, there is no opportunity to have two transactions
|
||||
# interleaving their cr.execute()..cr.commit() calls and have one
|
||||
# of them rolled back due to a concurrent access.)
|
||||
cr.autocommit(True)
|
||||
# check if user exists
|
||||
res = self.search(cr, 1, [('login','=',login)])
|
||||
if res:
|
||||
user_id = res[0]
|
||||
# check credentials
|
||||
self.check_credentials(cr, user_id, password)
|
||||
# We effectively unconditionally write the res_users line.
|
||||
# Even w/ autocommit there's a chance the user row will be locked,
|
||||
# in which case we can't delay the login just for the purpose of
|
||||
# update the last login date - hence we use FOR UPDATE NOWAIT to
|
||||
# try to get the lock - fail-fast
|
||||
# Failing to acquire the lock on the res_users row probably means
|
||||
# another request is holding it. No big deal, we don't want to
|
||||
# prevent/delay login in that case. It will also have been logged
|
||||
# as a SQL error, if anyone cares.
|
||||
try:
|
||||
cr.execute("SELECT id FROM res_users WHERE id=%s FOR UPDATE NOWAIT", str(user_id))
|
||||
cr.execute("UPDATE res_users SET login_date = now() AT TIME ZONE 'UTC' WHERE id=%s", str(user_id))
|
||||
except Exception, e:
|
||||
_logger.exception("Failed to update last_login for db:%s login:%s", db, login)
|
||||
except openerp.exceptions.AccessDenied:
|
||||
_logger.info("Login failed for db:%s login:%s", db, login)
|
||||
user_id = False
|
||||
finally:
|
||||
cr.close()
|
||||
|
||||
return user_id
|
||||
|
||||
def authenticate(self, db, login, password, user_agent_env):
|
||||
"""Verifies and returns the user ID corresponding to the given
|
||||
``login`` and ``password`` combination, or False if there was
|
||||
|
@ -429,8 +422,8 @@ class users(osv.osv):
|
|||
if user_agent_env and user_agent_env.get('base_location'):
|
||||
cr = pooler.get_db(db).cursor()
|
||||
try:
|
||||
self.pool.get('ir.config_parameter').set_param(cr, uid, 'web.base.url',
|
||||
user_agent_env['base_location'])
|
||||
base = user_agent_env['base_location']
|
||||
self.pool.get('ir.config_parameter').set_param(cr, uid, 'web.base.url', base)
|
||||
cr.commit()
|
||||
except Exception:
|
||||
_logger.exception("Failed to update web.base.url configuration parameter")
|
||||
|
@ -438,54 +431,8 @@ class users(osv.osv):
|
|||
cr.close()
|
||||
return uid
|
||||
|
||||
def login(self, db, login, password):
|
||||
if not password:
|
||||
return False
|
||||
cr = pooler.get_db(db).cursor()
|
||||
try:
|
||||
# autocommit: our single request will be performed atomically.
|
||||
# (In this way, there is no opportunity to have two transactions
|
||||
# interleaving their cr.execute()..cr.commit() calls and have one
|
||||
# of them rolled back due to a concurrent access.)
|
||||
# We effectively unconditionally write the res_users line.
|
||||
cr.autocommit(True)
|
||||
# Even w/ autocommit there's a chance the user row will be locked,
|
||||
# in which case we can't delay the login just for the purpose of
|
||||
# update the last login date - hence we use FOR UPDATE NOWAIT to
|
||||
# try to get the lock - fail-fast
|
||||
cr.execute("""SELECT id from res_users
|
||||
WHERE login=%s AND password=%s
|
||||
AND active FOR UPDATE NOWAIT""",
|
||||
(tools.ustr(login), tools.ustr(password)))
|
||||
cr.execute("""UPDATE res_users
|
||||
SET date = now() AT TIME ZONE 'UTC'
|
||||
WHERE login=%s AND password=%s AND active
|
||||
RETURNING id""",
|
||||
(tools.ustr(login), tools.ustr(password)))
|
||||
except Exception:
|
||||
# Failing to acquire the lock on the res_users row probably means
|
||||
# another request is holding it. No big deal, we don't want to
|
||||
# prevent/delay login in that case. It will also have been logged
|
||||
# as a SQL error, if anyone cares.
|
||||
cr.execute("""SELECT id from res_users
|
||||
WHERE login=%s AND password=%s
|
||||
AND active""",
|
||||
(tools.ustr(login), tools.ustr(password)))
|
||||
finally:
|
||||
res = cr.fetchone()
|
||||
cr.close()
|
||||
if res:
|
||||
return res[0]
|
||||
return False
|
||||
|
||||
def check_super(self, passwd):
|
||||
if passwd == tools.config['admin_passwd']:
|
||||
return True
|
||||
else:
|
||||
raise openerp.exceptions.AccessDenied()
|
||||
|
||||
def check(self, db, uid, passwd):
|
||||
"""Verifies that the given (uid, password) pair is authorized for the database ``db`` and
|
||||
"""Verifies that the given (uid, password) is authorized for the database ``db`` and
|
||||
raise an exception if it is not."""
|
||||
if not passwd:
|
||||
# empty passwords disallowed for obvious security reasons
|
||||
|
@ -494,32 +441,14 @@ class users(osv.osv):
|
|||
return
|
||||
cr = pooler.get_db(db).cursor()
|
||||
try:
|
||||
cr.execute('SELECT COUNT(1) FROM res_users WHERE id=%s AND password=%s AND active=%s',
|
||||
(int(uid), passwd, True))
|
||||
res = cr.fetchone()[0]
|
||||
if not res:
|
||||
raise openerp.exceptions.AccessDenied()
|
||||
self.check_credentials(cr, uid, passwd)
|
||||
if self._uid_cache.has_key(db):
|
||||
ulist = self._uid_cache[db]
|
||||
ulist[uid] = passwd
|
||||
self._uid_cache[db][uid] = passwd
|
||||
else:
|
||||
self._uid_cache[db] = {uid:passwd}
|
||||
finally:
|
||||
cr.close()
|
||||
|
||||
def access(self, db, uid, passwd, sec_level, ids):
|
||||
if not passwd:
|
||||
return False
|
||||
cr = pooler.get_db(db).cursor()
|
||||
try:
|
||||
cr.execute('SELECT id FROM res_users WHERE id=%s AND password=%s', (uid, passwd))
|
||||
res = cr.fetchone()
|
||||
if not res:
|
||||
raise openerp.exceptions.AccessDenied()
|
||||
return res[0]
|
||||
finally:
|
||||
cr.close()
|
||||
|
||||
def change_password(self, cr, uid, old_passwd, new_passwd, context=None):
|
||||
"""Change current user password. Old password must be provided explicitly
|
||||
to prevent hijacking an existing user session, or for cases where the cleartext
|
||||
|
@ -563,9 +492,6 @@ class users(osv.osv):
|
|||
(uid, module, ext_id))
|
||||
return bool(cr.fetchone())
|
||||
|
||||
users()
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Extension of res.groups and res.users with a relation for "implied" or
|
||||
|
@ -645,8 +571,6 @@ class groups_implied(osv.osv):
|
|||
super(groups_implied, self).write(cr, uid, gids, vals, context)
|
||||
return res
|
||||
|
||||
groups_implied()
|
||||
|
||||
class users_implied(osv.osv):
|
||||
_inherit = 'res.users'
|
||||
|
||||
|
@ -670,10 +594,6 @@ class users_implied(osv.osv):
|
|||
super(users_implied, self).write(cr, uid, [user.id], vals, context)
|
||||
return res
|
||||
|
||||
users_implied()
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Extension of res.groups and res.users for the special groups view in the users
|
||||
# form. This extension presents groups with selection and boolean widgets:
|
||||
|
@ -816,8 +736,6 @@ class groups_view(osv.osv):
|
|||
res.append((False, 'boolean', others))
|
||||
return res
|
||||
|
||||
groups_view()
|
||||
|
||||
class users_view(osv.osv):
|
||||
_inherit = 'res.users'
|
||||
|
||||
|
@ -909,6 +827,4 @@ class users_view(osv.osv):
|
|||
}
|
||||
return res
|
||||
|
||||
users_view()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<record id="view_groups_search" model="ir.ui.view">
|
||||
<field name="name">res.groups.search</field>
|
||||
<field name="model">res.groups</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Groups">
|
||||
<field name="name" filter_domain="['|', ('name','ilike',self), ('category_id','ilike',self)]" string="Group"/>
|
||||
|
@ -15,7 +14,6 @@
|
|||
<record id="view_groups_form" model="ir.ui.view">
|
||||
<field name="name">res.groups.form</field>
|
||||
<field name="model">res.groups</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Groups" version="7.0">
|
||||
<sheet>
|
||||
|
@ -86,7 +84,6 @@
|
|||
<record id="view_users_form" model="ir.ui.view">
|
||||
<field name="name">res.users.form</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Users" version="7.0">
|
||||
<field name="id" invisible="1"/>
|
||||
|
@ -112,8 +109,8 @@
|
|||
<page string="Preferences">
|
||||
<group>
|
||||
<group name="preferences">
|
||||
<field name="context_lang"/>
|
||||
<field name="context_tz"/>
|
||||
<field name="lang"/>
|
||||
<field name="tz"/>
|
||||
</group>
|
||||
<group groups="base.group_no_one">
|
||||
<field name="action_id"/>
|
||||
|
@ -121,7 +118,7 @@
|
|||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<field name="user_email" widget="email"/>
|
||||
<field name="email" widget="email"/>
|
||||
<field name="signature"/>
|
||||
</group>
|
||||
</page>
|
||||
|
@ -141,12 +138,11 @@
|
|||
<record id="view_users_tree" model="ir.ui.view">
|
||||
<field name="name">res.users.tree</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Users">
|
||||
<field name="name"/>
|
||||
<field name="login"/>
|
||||
<field name="context_lang"/>
|
||||
<field name="lang"/>
|
||||
<field name="date"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
@ -154,7 +150,6 @@
|
|||
<record id="view_users_search" model="ir.ui.view">
|
||||
<field name="name">res.users.search</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Users">
|
||||
<field name="name" filter_domain="['|', ('name','ilike',self), ('login','ilike',self)]" string="User"/>
|
||||
|
@ -197,7 +192,6 @@
|
|||
<record id="view_users_form_simple_modif" model="ir.ui.view">
|
||||
<field name="name">res.users.preferences.form</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="type">form</field>
|
||||
<field eval="18" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Users" version="7.0">
|
||||
|
@ -209,21 +203,22 @@
|
|||
(<field name="login" readonly="1" class="oe_inline"/>)
|
||||
</h1>
|
||||
<group name="preferences" col="4">
|
||||
<field name="context_lang" readonly="0"/>
|
||||
<field name="lang" readonly="0"/>
|
||||
<field name="company_id" readonly="0"
|
||||
groups="base.group_multi_company" on_change="on_change_company_id(company_id)"/>
|
||||
<field name="context_tz" readonly="0"/>
|
||||
<field name="tz" readonly="0"/>
|
||||
<field name="company_id" widget="selection" readonly="0"
|
||||
groups="base.group_multi_company" on_change="on_change_company_id(company_id)"/>
|
||||
</group>
|
||||
<group string="Email Preferences">
|
||||
<field name="user_email" widget="email" readonly="0"/>
|
||||
<field name="email" widget="email" readonly="0"/>
|
||||
<field name="signature" readonly="0"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="preference_save" type="object" string="Save"/>
|
||||
<button name="preference_cancel" special="cancel" string="Cancel"/>
|
||||
<button name="preference_change_password" type="object" string="Change password"/>
|
||||
<button name="preference_save" type="object" string="Save"/>
|
||||
or
|
||||
<button name="preference_cancel" string="Cancel" special="cancel" class="oe_link"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
<record id="view_res_widget_search" model="ir.ui.view">
|
||||
<field name="name">res.widget.search</field>
|
||||
<field name="model">res.widget</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Widget">
|
||||
<field name="title" string="Widget"/>
|
||||
|
@ -14,7 +13,6 @@
|
|||
<record id="res_widget_form" model="ir.ui.view">
|
||||
<field name="name">res.widget.form</field>
|
||||
<field name="model">res.widget</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Widgets" version="7.0">
|
||||
<sheet>
|
||||
|
@ -29,7 +27,6 @@
|
|||
<record id="res_widget_tree" model="ir.ui.view">
|
||||
<field name="name">res.widget.tree</field>
|
||||
<field name="model">res.widget</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Widgets">
|
||||
<field name="title"/>
|
||||
|
@ -49,7 +46,6 @@
|
|||
<record id="res_widget_user_tree" model="ir.ui.view">
|
||||
<field name="name">res.widget.user.tree</field>
|
||||
<field name="model">res.widget.user</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="User Widgets">
|
||||
<field name="sequence" invisible="1"/>
|
||||
|
@ -61,7 +57,6 @@
|
|||
<record id="res_widget_user_form" model="ir.ui.view">
|
||||
<field name="name">res.widget.user.form</field>
|
||||
<field name="model">res.widget.user</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="User Widgets" version="7.0">
|
||||
<sheet>
|
||||
|
@ -85,7 +80,6 @@
|
|||
<record id="view_res_widget_wizard" model="ir.ui.view">
|
||||
<field name="name">Homepage Widgets Management</field>
|
||||
<field name="model">res.widget.wizard</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Widget Wizard" col="4" version="7.0">
|
||||
<header>
|
||||
|
|
|
@ -181,9 +181,12 @@
|
|||
|
||||
<rng:define name="diagram">
|
||||
<rng:element name="diagram">
|
||||
<rng:optional><rng:attribute name="string"/></rng:optional>
|
||||
<rng:optional><rng:attribute name="string"/></rng:optional>
|
||||
<rng:ref name="node"/>
|
||||
<rng:ref name="arrow"/>
|
||||
<rng:ref name="arrow"/>
|
||||
<rng:zeroOrMore>
|
||||
<rng:ref name="label"/>
|
||||
</rng:zeroOrMore>
|
||||
</rng:element>
|
||||
</rng:define>
|
||||
|
||||
|
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
|
@ -7,7 +7,7 @@
|
|||
-->
|
||||
|
||||
<assert model="res.request" id="res_partner_asustek_request" string="Reference field request returns a browsable object">
|
||||
<test expr="ref_doc1.name">ASUStek</test>
|
||||
<test expr="ref_doc1.name">ASUSTeK</test>
|
||||
</assert>
|
||||
|
||||
</data>
|
||||
|
|
|
@ -2,22 +2,8 @@
|
|||
Testing for hierarchical search in M2M
|
||||
-
|
||||
!python {model: res.partner }: |
|
||||
ids = self.search(cr, uid, [('category_id', 'child_of','supplier')])
|
||||
ids = self.search(cr, uid, [('category_id', 'child_of',ref('res_partner_category_0'))])
|
||||
assert len(ids) >= 1, ids
|
||||
|
||||
-
|
||||
Test hierarchical search in M2M with child ID1
|
||||
-
|
||||
!python {model: res.partner }: |
|
||||
ids = self.search(cr, uid, [('category_id', 'child_of','Components Supplier')])
|
||||
assert len(ids) >= 1, ids
|
||||
-
|
||||
Test hierarchical search in M2M with child ID2
|
||||
-
|
||||
!python {model: res.partner }: |
|
||||
ids = self.search(cr, uid, [('category_id', 'child_of','Miscellaneous Suppliers')])
|
||||
assert len(ids) >= 1, ids
|
||||
|
||||
-
|
||||
"1.0 Setup test partner categories: parent root"
|
||||
-
|
||||
|
@ -464,8 +450,8 @@
|
|||
!python {model: res.partner }: |
|
||||
all_ids = self.search(cr, uid, [('name', '=like', 'A_e_or')])
|
||||
assert len(all_ids) == 1, "Must match one partner (Axelor), got %r"%all_ids
|
||||
all_ids = self.search(cr, uid, [('name', '=ilike', 'm_____')])
|
||||
assert len(all_ids) == 1, "Must match *only* one partner (Maxtor), got %r"%all_ids
|
||||
all_ids = self.search(cr, uid, [('name', '=ilike', 'v%')])
|
||||
assert len(all_ids) >= 1, "Must match one partner (Vicking Direct), got %r"%all_ids
|
||||
-
|
||||
Check that =like/=ilike expressions (no wildcard variants of like/ilike) are working on translated field.
|
||||
-
|
||||
|
@ -512,7 +498,7 @@
|
|||
Testing for Many2Many field with category supplier and active=False
|
||||
-
|
||||
!python {model: res.partner }: |
|
||||
vals = {'category_id': [(6, 0, [ref("base.res_partner_category_8")])],
|
||||
vals = {'category_id': [(6, 0, [ref("base.res_partner_category_1")])],
|
||||
'name': 'OpenERP Test',
|
||||
'active': False,
|
||||
'child_ids': [(0, 0, {'name': 'address of OpenERP Test', 'country_id': ref("base.be")})]
|
||||
|
|
|
@ -24,11 +24,7 @@
|
|||
|
||||
"""
|
||||
|
||||
import openerp.modules.db
|
||||
import openerp.modules.graph
|
||||
import openerp.modules.loading
|
||||
import openerp.modules.migration
|
||||
import openerp.modules.module
|
||||
from . import db, graph, loading, migration, module, registry
|
||||
|
||||
# TODO temporarily expose those things
|
||||
from openerp.modules.module import \
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
""" Models registries.
|
||||
|
||||
"""
|
||||
from contextlib import contextmanager
|
||||
import logging
|
||||
import threading
|
||||
|
||||
|
@ -43,12 +44,12 @@ class Registry(object):
|
|||
"""
|
||||
|
||||
def __init__(self, db_name):
|
||||
self.models = {} # model name/model instance mapping
|
||||
self.models = {} # model name/model instance mapping
|
||||
self._sql_error = {}
|
||||
self._store_function = {}
|
||||
self._init = True
|
||||
self._init_parent = {}
|
||||
|
||||
|
||||
# modules fully loaded (maintained during init phase by `loading` module)
|
||||
self._init_modules = set()
|
||||
|
||||
|
@ -119,6 +120,17 @@ class Registry(object):
|
|||
for model in self.models.itervalues():
|
||||
model.clear_caches()
|
||||
|
||||
@contextmanager
|
||||
def cursor(self, auto_commit=True):
|
||||
cr = self.db.cursor()
|
||||
try:
|
||||
yield cr
|
||||
if auto_commit:
|
||||
cr.commit()
|
||||
finally:
|
||||
cr.close()
|
||||
|
||||
|
||||
class RegistryManager(object):
|
||||
""" Model registries manager.
|
||||
|
||||
|
@ -196,7 +208,6 @@ class RegistryManager(object):
|
|||
del cls.registries[db_name]
|
||||
openerp.cron.cancel(db_name)
|
||||
|
||||
|
||||
@classmethod
|
||||
def delete_all(cls):
|
||||
"""Delete all the registries. """
|
||||
|
|
|
@ -45,6 +45,7 @@ import openerp.tools as tools
|
|||
from openerp.tools.translate import _
|
||||
from openerp.tools import float_round, float_repr
|
||||
import simplejson
|
||||
from openerp.tools.html_sanitize import html_sanitize
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -109,6 +110,7 @@ class _column(object):
|
|||
self.selectable = True
|
||||
self.group_operator = args.get('group_operator', False)
|
||||
self.groups = False # CSV list of ext IDs of groups that can access this field
|
||||
self.deprecated = False # Optional deprecation warning
|
||||
for a in args:
|
||||
if args[a]:
|
||||
setattr(self, a, args[a])
|
||||
|
@ -227,6 +229,14 @@ class char(_column):
|
|||
class text(_column):
|
||||
_type = 'text'
|
||||
|
||||
class html(text):
|
||||
_type = 'html'
|
||||
_symbol_c = '%s'
|
||||
def _symbol_f(x):
|
||||
return html_sanitize(x)
|
||||
|
||||
_symbol_set = (_symbol_c, _symbol_f)
|
||||
|
||||
import __builtin__
|
||||
|
||||
class float(_column):
|
||||
|
@ -648,6 +658,20 @@ class many2many(_column):
|
|||
col2 = '%s_id' % dest_model._table
|
||||
return (tbl, col1, col2)
|
||||
|
||||
def _get_query_and_where_params(self, cr, model, ids, values, where_params):
|
||||
""" Extracted from ``get`` to facilitate fine-tuning of the generated
|
||||
query. """
|
||||
query = 'SELECT %(rel)s.%(id2)s, %(rel)s.%(id1)s \
|
||||
FROM %(rel)s, %(from_c)s \
|
||||
WHERE %(rel)s.%(id1)s IN %%s \
|
||||
AND %(rel)s.%(id2)s = %(tbl)s.id \
|
||||
%(where_c)s \
|
||||
%(order_by)s \
|
||||
%(limit)s \
|
||||
OFFSET %(offset)d' \
|
||||
% values
|
||||
return query, where_params
|
||||
|
||||
def get(self, cr, model, ids, name, user=None, offset=0, context=None, values=None):
|
||||
if not context:
|
||||
context = {}
|
||||
|
@ -685,15 +709,7 @@ class many2many(_column):
|
|||
if self._limit is not None:
|
||||
limit_str = ' LIMIT %d' % self._limit
|
||||
|
||||
query = 'SELECT %(rel)s.%(id2)s, %(rel)s.%(id1)s \
|
||||
FROM %(rel)s, %(from_c)s \
|
||||
WHERE %(rel)s.%(id1)s IN %%s \
|
||||
AND %(rel)s.%(id2)s = %(tbl)s.id \
|
||||
%(where_c)s \
|
||||
%(order_by)s \
|
||||
%(limit)s \
|
||||
OFFSET %(offset)d' \
|
||||
% {'rel': rel,
|
||||
query, where_params = self._get_query_and_where_params(cr, model, ids, {'rel': rel,
|
||||
'from_c': from_c,
|
||||
'tbl': obj._table,
|
||||
'id1': id1,
|
||||
|
@ -702,7 +718,8 @@ class many2many(_column):
|
|||
'limit': limit_str,
|
||||
'order_by': order_by,
|
||||
'offset': offset,
|
||||
}
|
||||
}, where_params)
|
||||
|
||||
cr.execute(query, [tuple(ids),] + where_params)
|
||||
for r in cr.fetchall():
|
||||
res[r[1]].append(r[0])
|
||||
|
|
|
@ -545,6 +545,7 @@ FIELDS_TO_PGTYPES = {
|
|||
fields.boolean: 'bool',
|
||||
fields.integer: 'int4',
|
||||
fields.text: 'text',
|
||||
fields.html: 'text',
|
||||
fields.date: 'date',
|
||||
fields.datetime: 'timestamp',
|
||||
fields.binary: 'bytea',
|
||||
|
@ -2442,9 +2443,9 @@ class BaseModel(object):
|
|||
context=context)
|
||||
|
||||
result_template = dict.fromkeys(aggregated_fields, False)
|
||||
result_template.update({groupby + '_count':0})
|
||||
result_template[groupby + '_count'] = 0
|
||||
if groupby_list and len(groupby_list) > 1:
|
||||
result_template.update(__context={'group_by': groupby_list[1:]})
|
||||
result_template['__context'] = {'group_by': groupby_list[1:]}
|
||||
|
||||
# Merge the left_side (current results as dicts) with the right_side (all
|
||||
# possible values as m2o pairs). Both lists are supposed to be using the
|
||||
|
@ -2463,10 +2464,8 @@ class BaseModel(object):
|
|||
grouped_value = right_side[0]
|
||||
if not grouped_value in known_values:
|
||||
line = dict(result_template)
|
||||
line.update({
|
||||
groupby: right_side,
|
||||
'__domain': [(groupby,'=',grouped_value)] + domain,
|
||||
})
|
||||
line[groupby] = right_side
|
||||
line['__domain'] = [(groupby,'=',grouped_value)] + domain
|
||||
result.append(line)
|
||||
known_values[grouped_value] = line
|
||||
while read_group_result or all_groups:
|
||||
|
@ -3598,6 +3597,14 @@ class BaseModel(object):
|
|||
record[f] = res2[record['id']]
|
||||
else:
|
||||
record[f] = []
|
||||
|
||||
# Warn about deprecated fields now that fields_pre and fields_post are computed
|
||||
# Explicitly use list() because we may receive tuples
|
||||
for f in list(fields_pre) + list(fields_post):
|
||||
field_column = self._all_columns.get(f) and self._all_columns.get(f).column
|
||||
if field_column and field_column.deprecated:
|
||||
_logger.warning('Field %s.%s is deprecated: %s', self._name, f, field_column.deprecated)
|
||||
|
||||
readonly = None
|
||||
for vals in res:
|
||||
for field in vals.copy():
|
||||
|
@ -3975,6 +3982,9 @@ class BaseModel(object):
|
|||
direct = []
|
||||
totranslate = context.get('lang', False) and (context['lang'] != 'en_US')
|
||||
for field in vals:
|
||||
field_column = self._all_columns.get(field) and self._all_columns.get(field).column
|
||||
if field_column and field_column.deprecated:
|
||||
_logger.warning('Field %s.%s is deprecated: %s', self._name, field, field_column.deprecated)
|
||||
if field in self._columns:
|
||||
if self._columns[field]._classic_write and not (hasattr(self._columns[field], '_fnct_inv')):
|
||||
if (not totranslate) or not self._columns[field].translate:
|
||||
|
@ -4197,7 +4207,7 @@ class BaseModel(object):
|
|||
cr.execute("SELECT nextval('"+self._sequence+"')")
|
||||
except:
|
||||
raise except_orm(_('UserError'),
|
||||
_('You cannot perform this operation. New Record Creation is not allowed for this object as this object is for reporting purpose.'))
|
||||
_('You cannot perform this operation. New Record Creation is not allowed for this object as this object is for reporting purpose.'))
|
||||
|
||||
id_new = cr.fetchone()[0]
|
||||
for table in tocreate:
|
||||
|
|
|
@ -30,9 +30,9 @@ RELEASE_LEVELS_DISPLAY = {ALPHA: ALPHA,
|
|||
# properly comparable using normal operarors, for example:
|
||||
# (6,1,0,'beta',0) < (6,1,0,'candidate',1) < (6,1,0,'candidate',2)
|
||||
# (6,1,0,'candidate',2) < (6,1,0,'final',0) < (6,1,2,'final',0)
|
||||
version_info = (6,2,0,ALPHA,0)
|
||||
version = '.'.join(map(str,version_info[:2])) + RELEASE_LEVELS_DISPLAY[version_info[3]] + str(version_info[4] or '')
|
||||
major_version = '.'.join(map(str,version_info[:2]))
|
||||
version_info = (7, 0, 0, ALPHA, 0)
|
||||
version = '.'.join(map(str, version_info[:2])) + RELEASE_LEVELS_DISPLAY[version_info[3]] + str(version_info[4] or '')
|
||||
serie = major_version = '.'.join(map(str, version_info[:2]))
|
||||
|
||||
description = 'OpenERP Server'
|
||||
long_desc = '''OpenERP is a complete ERP and CRM. The main features are accounting (analytic
|
||||
|
|
|
@ -75,10 +75,10 @@ def _initialize_db(serv, id, db_name, demo, lang, user_password):
|
|||
mids = modobj.search(cr, 1, [('state', '=', 'installed')])
|
||||
modobj.update_translations(cr, 1, mids, lang)
|
||||
|
||||
cr.execute('UPDATE res_users SET password=%s, context_lang=%s, active=True WHERE login=%s', (
|
||||
cr.execute('UPDATE res_users SET password=%s, lang=%s, active=True WHERE login=%s', (
|
||||
user_password, lang, 'admin'))
|
||||
cr.execute('SELECT login, password, name ' \
|
||||
' FROM res_users ' \
|
||||
cr.execute('SELECT login, password ' \
|
||||
' FROM res_users ' \
|
||||
' ORDER BY login')
|
||||
serv.actions[id].update(users=cr.dictfetchall(), clean=True)
|
||||
cr.commit()
|
||||
|
@ -425,7 +425,7 @@ OpenERP is an ERP+CRM program for small and medium businesses.
|
|||
The whole source code is distributed under the terms of the
|
||||
GNU Public Licence.
|
||||
|
||||
(c) 2003-TODAY, Fabien Pinckaers - Tiny sprl''')
|
||||
(c) 2003-TODAY - OpenERP SA''')
|
||||
|
||||
if extended:
|
||||
return info, release.version
|
||||
|
|
|
@ -8,18 +8,18 @@ Tests can be explicitely added to the `fast_suite` or `checks` lists or not.
|
|||
See the :ref:`test-framework` section in the :ref:`features` list.
|
||||
"""
|
||||
|
||||
import test_expression
|
||||
import test_ir_sequence
|
||||
import test_orm
|
||||
import test_uninstall
|
||||
from . import test_expression, test_html_sanitize, test_ir_sequence, test_orm,\
|
||||
test_view_validation, test_uninstall
|
||||
|
||||
fast_suite = [
|
||||
test_ir_sequence,
|
||||
]
|
||||
]
|
||||
|
||||
checks = [
|
||||
test_expression,
|
||||
test_html_sanitize,
|
||||
test_orm,
|
||||
]
|
||||
test_view_validation,
|
||||
]
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<record id="view_test_exceptions_model" model="ir.ui.view">
|
||||
<field name="name">Test exceptions</field>
|
||||
<field name="model">test.exceptions.model</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Test exceptions">
|
||||
<label string="Each button generates a specific exception on the server. The text on the right is the expected representation of the exception when displayed on the client."/>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
import models
|
|
@ -0,0 +1,15 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
{
|
||||
'name': 'test-import-export',
|
||||
'version': '0.1',
|
||||
'category': 'Tests',
|
||||
'description': """A module to test import/export.""",
|
||||
'author': 'OpenERP SA',
|
||||
'maintainer': 'OpenERP SA',
|
||||
'website': 'http://www.openerp.com',
|
||||
'depends': ['base'],
|
||||
'data': [],
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
}
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,118 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from openerp.osv import orm, fields
|
||||
|
||||
def selection_fn(obj, cr, uid, context=None):
|
||||
return list(enumerate(["Corge", "Grault", "Wheee", "Moog"]))
|
||||
|
||||
def function_fn(model, cr, uid, ids, field_name, arg, context):
|
||||
return dict((id, 3) for id in ids)
|
||||
def function_fn_write(model, cr, uid, id, field_name, field_value, fnct_inv_arg, context):
|
||||
""" just so CreatorCase.export can be used
|
||||
"""
|
||||
pass
|
||||
|
||||
models = [
|
||||
('boolean', fields.boolean()),
|
||||
('integer', fields.integer()),
|
||||
('float', fields.float()),
|
||||
('decimal', fields.float(digits=(16, 3))),
|
||||
('string.bounded', fields.char('unknown', size=16)),
|
||||
('string', fields.char('unknown', size=None)),
|
||||
('date', fields.date()),
|
||||
('datetime', fields.datetime()),
|
||||
('text', fields.text()),
|
||||
('selection', fields.selection([(1, "Foo"), (2, "Bar"), (3, "Qux")])),
|
||||
('selection.function', fields.selection(selection_fn)),
|
||||
# just relate to an integer
|
||||
('many2one', fields.many2one('export.integer')),
|
||||
('one2many', fields.one2many('export.one2many.child', 'parent_id')),
|
||||
('many2many', fields.many2many('export.many2many.other')),
|
||||
('function', fields.function(function_fn, fnct_inv=function_fn_write, type="integer")),
|
||||
# related: specialization of fields.function, should work the same way
|
||||
# TODO: reference
|
||||
]
|
||||
for name, field in models:
|
||||
attrs = {
|
||||
'_name': 'export.%s' % name,
|
||||
'_columns': {
|
||||
'const': fields.integer(),
|
||||
'value': field
|
||||
},
|
||||
'_defaults': {'const': 4},
|
||||
'name_get': (lambda self, cr, uid, ids, context=None:
|
||||
[(record.id, "%s:%s" % (self._name, record.value))
|
||||
for record in self.browse(cr, uid, ids, context=context)]),
|
||||
'name_search': (lambda self, cr, uid, name, operator, context=None:
|
||||
self.name_get(cr, uid,
|
||||
self.search(cr, uid, [['value', operator, int(name.split(':')[1])]])
|
||||
, context=context)
|
||||
if isinstance(name, basestring) and name.split(':')[0] == self._name
|
||||
else [])
|
||||
}
|
||||
NewModel = type(
|
||||
'Export%s' % ''.join(section.capitalize() for section in name.split('.')),
|
||||
(orm.Model,),
|
||||
attrs)
|
||||
|
||||
class One2ManyChild(orm.Model):
|
||||
_name = 'export.one2many.child'
|
||||
# FIXME: orm.py:1161, fix to name_get on m2o field
|
||||
_rec_name = 'value'
|
||||
|
||||
_columns = {
|
||||
'parent_id': fields.many2one('export.one2many'),
|
||||
'str': fields.char('unknown', size=None),
|
||||
'value': fields.integer()
|
||||
}
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
return [(record.id, "%s:%s" % (self._name, record.value))
|
||||
for record in self.browse(cr, uid, ids, context=context)]
|
||||
|
||||
class One2ManyMultiple(orm.Model):
|
||||
_name = 'export.one2many.multiple'
|
||||
|
||||
_columns = {
|
||||
'const': fields.integer(),
|
||||
'child1': fields.one2many('export.one2many.child.1', 'parent_id'),
|
||||
'child2': fields.one2many('export.one2many.child.2', 'parent_id'),
|
||||
}
|
||||
_defaults = { 'const': 36 }
|
||||
|
||||
class One2ManyChildMultiple(orm.Model):
|
||||
_name = 'export.one2many.multiple.child'
|
||||
# FIXME: orm.py:1161, fix to name_get on m2o field
|
||||
_rec_name = 'value'
|
||||
|
||||
_columns = {
|
||||
'parent_id': fields.many2one('export.one2many.multiple'),
|
||||
'str': fields.char('unknown', size=None),
|
||||
'value': fields.integer()
|
||||
}
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
return [(record.id, "%s:%s" % (self._name, record.value))
|
||||
for record in self.browse(cr, uid, ids, context=context)]
|
||||
class One2ManyChild1(orm.Model):
|
||||
_name = 'export.one2many.child.1'
|
||||
_inherit = 'export.one2many.multiple.child'
|
||||
class One2ManyChild2(orm.Model):
|
||||
_name = 'export.one2many.child.2'
|
||||
_inherit = 'export.one2many.multiple.child'
|
||||
|
||||
class Many2ManyChild(orm.Model):
|
||||
_name = 'export.many2many.other'
|
||||
# FIXME: orm.py:1161, fix to name_get on m2o field
|
||||
_rec_name = 'value'
|
||||
|
||||
_columns = {
|
||||
'str': fields.char('unknown', size=None),
|
||||
'value': fields.integer()
|
||||
}
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
return [(record.id, "%s:%s" % (self._name, record.value))
|
||||
for record in self.browse(cr, uid, ids, context=context)]
|
||||
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100):
|
||||
return (self.name_get(cr, user,
|
||||
self.search(cr, user, [['value', operator, int(name.split(':')[1])]])
|
||||
, context=context)
|
||||
if isinstance(name, basestring) and name.split(':')[0] == self._name
|
||||
else [])
|
|
@ -0,0 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import test_export, test_import
|
||||
|
||||
fast_suite = [
|
||||
]
|
||||
|
||||
checks = [
|
||||
test_export,
|
||||
test_import,
|
||||
]
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,589 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import itertools
|
||||
import openerp.modules.registry
|
||||
import openerp
|
||||
|
||||
from openerp.tests import common
|
||||
|
||||
|
||||
class CreatorCase(common.TransactionCase):
|
||||
model_name = False
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(CreatorCase, self).__init__(*args, **kwargs)
|
||||
self.model = None
|
||||
|
||||
def setUp(self):
|
||||
super(CreatorCase, self).setUp()
|
||||
self.model = self.registry(self.model_name)
|
||||
def make(self, value):
|
||||
id = self.model.create(self.cr, openerp.SUPERUSER_ID, {'value': value})
|
||||
return self.model.browse(self.cr, openerp.SUPERUSER_ID, [id])[0]
|
||||
def export(self, value, fields=('value',), context=None):
|
||||
record = self.make(value)
|
||||
return self.model._BaseModel__export_row(
|
||||
self.cr, openerp.SUPERUSER_ID, record,
|
||||
[f.split('/') for f in fields],
|
||||
context=context)
|
||||
|
||||
class test_boolean_field(CreatorCase):
|
||||
model_name = 'export.boolean'
|
||||
|
||||
def test_true(self):
|
||||
self.assertEqual(
|
||||
self.export(True),
|
||||
[[u'True']])
|
||||
def test_false(self):
|
||||
""" ``False`` value to boolean fields is unique in being exported as a
|
||||
(unicode) string, not a boolean
|
||||
"""
|
||||
self.assertEqual(
|
||||
self.export(False),
|
||||
[[u'False']])
|
||||
|
||||
class test_integer_field(CreatorCase):
|
||||
model_name = 'export.integer'
|
||||
|
||||
def test_empty(self):
|
||||
self.assertEqual(self.model.search(self.cr, openerp.SUPERUSER_ID, []), [],
|
||||
"Test model should have no records")
|
||||
def test_0(self):
|
||||
self.assertEqual(
|
||||
self.export(0),
|
||||
[[False]])
|
||||
|
||||
def test_basic_value(self):
|
||||
self.assertEqual(
|
||||
self.export(42),
|
||||
[[u'42']])
|
||||
|
||||
def test_negative(self):
|
||||
self.assertEqual(
|
||||
self.export(-32),
|
||||
[[u'-32']])
|
||||
|
||||
def test_huge(self):
|
||||
self.assertEqual(
|
||||
self.export(2**31-1),
|
||||
[[unicode(2**31-1)]])
|
||||
|
||||
class test_float_field(CreatorCase):
|
||||
model_name = 'export.float'
|
||||
|
||||
def test_0(self):
|
||||
self.assertEqual(
|
||||
self.export(0.0),
|
||||
[[False]])
|
||||
|
||||
def test_epsilon(self):
|
||||
self.assertEqual(
|
||||
self.export(0.000000000027),
|
||||
[[u'2.7e-11']])
|
||||
|
||||
def test_negative(self):
|
||||
self.assertEqual(
|
||||
self.export(-2.42),
|
||||
[[u'-2.42']])
|
||||
|
||||
def test_positive(self):
|
||||
self.assertEqual(
|
||||
self.export(47.36),
|
||||
[[u'47.36']])
|
||||
|
||||
def test_big(self):
|
||||
self.assertEqual(
|
||||
self.export(87654321.4678),
|
||||
[[u'87654321.4678']])
|
||||
|
||||
class test_decimal_field(CreatorCase):
|
||||
model_name = 'export.decimal'
|
||||
|
||||
def test_0(self):
|
||||
self.assertEqual(
|
||||
self.export(0.0),
|
||||
[[False]])
|
||||
|
||||
def test_epsilon(self):
|
||||
""" epsilon gets sliced to 0 due to precision
|
||||
"""
|
||||
self.assertEqual(
|
||||
self.export(0.000000000027),
|
||||
[[False]])
|
||||
|
||||
def test_negative(self):
|
||||
self.assertEqual(
|
||||
self.export(-2.42),
|
||||
[[u'-2.42']])
|
||||
|
||||
def test_positive(self):
|
||||
self.assertEqual(
|
||||
self.export(47.36),
|
||||
[[u'47.36']])
|
||||
|
||||
def test_big(self):
|
||||
self.assertEqual(
|
||||
self.export(87654321.4678), [[u'87654321.468']])
|
||||
|
||||
class test_string_field(CreatorCase):
|
||||
model_name = 'export.string.bounded'
|
||||
|
||||
def test_empty(self):
|
||||
self.assertEqual(
|
||||
self.export(""),
|
||||
[[False]])
|
||||
def test_within_bounds(self):
|
||||
self.assertEqual(
|
||||
self.export("foobar"),
|
||||
[[u"foobar"]])
|
||||
def test_out_of_bounds(self):
|
||||
self.assertEqual(
|
||||
self.export("C for Sinking, "
|
||||
"Java for Drinking, "
|
||||
"Smalltalk for Thinking. "
|
||||
"...and Power to the Penguin!"),
|
||||
[[u"C for Sinking, J"]])
|
||||
|
||||
class test_unbound_string_field(CreatorCase):
|
||||
model_name = 'export.string'
|
||||
|
||||
def test_empty(self):
|
||||
self.assertEqual(
|
||||
self.export(""),
|
||||
[[False]])
|
||||
def test_small(self):
|
||||
self.assertEqual(
|
||||
self.export("foobar"),
|
||||
[[u"foobar"]])
|
||||
def test_big(self):
|
||||
self.assertEqual(
|
||||
self.export("We flew down weekly to meet with IBM, but they "
|
||||
"thought the way to measure software was the amount "
|
||||
"of code we wrote, when really the better the "
|
||||
"software, the fewer lines of code."),
|
||||
[[u"We flew down weekly to meet with IBM, but they thought the "
|
||||
u"way to measure software was the amount of code we wrote, "
|
||||
u"when really the better the software, the fewer lines of "
|
||||
u"code."]])
|
||||
|
||||
class test_text(CreatorCase):
|
||||
model_name = 'export.text'
|
||||
|
||||
def test_empty(self):
|
||||
self.assertEqual(
|
||||
self.export(""),
|
||||
[[False]])
|
||||
def test_small(self):
|
||||
self.assertEqual(
|
||||
self.export("foobar"),
|
||||
[[u"foobar"]])
|
||||
def test_big(self):
|
||||
self.assertEqual(
|
||||
self.export("So, `bind' is `let' and monadic programming is"
|
||||
" equivalent to programming in the A-normal form. That"
|
||||
" is indeed all there is to monads"),
|
||||
[[u"So, `bind' is `let' and monadic programming is equivalent to"
|
||||
u" programming in the A-normal form. That is indeed all there"
|
||||
u" is to monads"]])
|
||||
|
||||
class test_date(CreatorCase):
|
||||
model_name = 'export.date'
|
||||
|
||||
def test_empty(self):
|
||||
self.assertEqual(
|
||||
self.export(False),
|
||||
[[False]])
|
||||
def test_basic(self):
|
||||
self.assertEqual(
|
||||
self.export('2011-11-07'),
|
||||
[[u'2011-11-07']])
|
||||
|
||||
class test_datetime(CreatorCase):
|
||||
model_name = 'export.datetime'
|
||||
|
||||
def test_empty(self):
|
||||
self.assertEqual(
|
||||
self.export(False),
|
||||
[[False]])
|
||||
def test_basic(self):
|
||||
self.assertEqual(
|
||||
self.export('2011-11-07 21:05:48'),
|
||||
[[u'2011-11-07 21:05:48']])
|
||||
def test_tz(self):
|
||||
""" Export ignores the timezone and always exports to UTC
|
||||
|
||||
.. note:: on the other hand, export uses user lang for name_get
|
||||
"""
|
||||
# NOTE: ignores user timezone, always exports to UTC
|
||||
self.assertEqual(
|
||||
self.export('2011-11-07 21:05:48', context={'tz': 'Pacific/Norfolk'}),
|
||||
[[u'2011-11-07 21:05:48']])
|
||||
|
||||
class test_selection(CreatorCase):
|
||||
model_name = 'export.selection'
|
||||
translations_fr = [
|
||||
("Qux", "toto"),
|
||||
("Bar", "titi"),
|
||||
("Foo", "tete"),
|
||||
]
|
||||
|
||||
def test_empty(self):
|
||||
self.assertEqual(
|
||||
self.export(False),
|
||||
[[False]])
|
||||
|
||||
def test_value(self):
|
||||
""" selections export the *label* for their value
|
||||
"""
|
||||
self.assertEqual(
|
||||
self.export(2),
|
||||
[[u"Bar"]])
|
||||
|
||||
def test_localized_export(self):
|
||||
self.registry('res.lang').create(self.cr, openerp.SUPERUSER_ID, {
|
||||
'name': u'Français',
|
||||
'code': 'fr_FR',
|
||||
'translatable': True,
|
||||
'date_format': '%d.%m.%Y',
|
||||
'decimal_point': ',',
|
||||
'thousand_sep': ' ',
|
||||
})
|
||||
Translations = self.registry('ir.translation')
|
||||
for source, value in self.translations_fr:
|
||||
Translations.create(self.cr, openerp.SUPERUSER_ID, {
|
||||
'name': 'export.selection,value',
|
||||
'lang': 'fr_FR',
|
||||
'type': 'selection',
|
||||
'src': source,
|
||||
'value': value
|
||||
})
|
||||
self.assertEqual(
|
||||
self.export(2, context={'lang': 'fr_FR'}),
|
||||
[[u'Bar']])
|
||||
|
||||
class test_selection_function(CreatorCase):
|
||||
model_name = 'export.selection.function'
|
||||
|
||||
def test_empty(self):
|
||||
self.assertEqual(
|
||||
self.export(False),
|
||||
[[False]])
|
||||
|
||||
def test_value(self):
|
||||
# FIXME: selection functions export the *value* itself
|
||||
self.assertEqual(
|
||||
self.export(1),
|
||||
[[u'1']])
|
||||
self.assertEqual(
|
||||
self.export(3),
|
||||
[[u'3']])
|
||||
# fucking hell
|
||||
self.assertEqual(
|
||||
self.export(0),
|
||||
[[False]])
|
||||
|
||||
class test_m2o(CreatorCase):
|
||||
model_name = 'export.many2one'
|
||||
|
||||
def test_empty(self):
|
||||
self.assertEqual(
|
||||
self.export(False),
|
||||
[[False]])
|
||||
def test_basic(self):
|
||||
""" Exported value is the name_get of the related object
|
||||
"""
|
||||
integer_id = self.registry('export.integer').create(
|
||||
self.cr, openerp.SUPERUSER_ID, {'value': 42})
|
||||
name = dict(self.registry('export.integer').name_get(
|
||||
self.cr, openerp.SUPERUSER_ID,[integer_id]))[integer_id]
|
||||
self.assertEqual(
|
||||
self.export(integer_id),
|
||||
[[name]])
|
||||
def test_path(self):
|
||||
""" Can recursively export fields of m2o via path
|
||||
"""
|
||||
integer_id = self.registry('export.integer').create(
|
||||
self.cr, openerp.SUPERUSER_ID, {'value': 42})
|
||||
self.assertEqual(
|
||||
self.export(integer_id, fields=['value/.id', 'value/value']),
|
||||
[[unicode(integer_id), u'42']])
|
||||
def test_external_id(self):
|
||||
integer_id = self.registry('export.integer').create(
|
||||
self.cr, openerp.SUPERUSER_ID, {'value': 42})
|
||||
# __export__.$class.$id
|
||||
external_id = u'__export__.export_many2one_%d' % integer_id
|
||||
self.assertEqual(
|
||||
self.export(integer_id, fields=['value/id']),
|
||||
[[external_id]])
|
||||
|
||||
class test_o2m(CreatorCase):
|
||||
model_name = 'export.one2many'
|
||||
commands = [
|
||||
(0, False, {'value': 4, 'str': 'record1'}),
|
||||
(0, False, {'value': 42, 'str': 'record2'}),
|
||||
(0, False, {'value': 36, 'str': 'record3'}),
|
||||
(0, False, {'value': 4, 'str': 'record4'}),
|
||||
(0, False, {'value': 13, 'str': 'record5'}),
|
||||
]
|
||||
names = [
|
||||
u'export.one2many.child:%d' % d['value']
|
||||
for c, _, d in commands
|
||||
]
|
||||
|
||||
def test_empty(self):
|
||||
self.assertEqual(
|
||||
self.export(False),
|
||||
[[False]])
|
||||
|
||||
def test_single(self):
|
||||
self.assertEqual(
|
||||
self.export([(0, False, {'value': 42})]),
|
||||
# name_get result
|
||||
[[u'export.one2many.child:42']])
|
||||
|
||||
def test_single_subfield(self):
|
||||
self.assertEqual(
|
||||
self.export([(0, False, {'value': 42})],
|
||||
fields=['value', 'value/value']),
|
||||
[[u'export.one2many.child:42', u'42']])
|
||||
|
||||
def test_integrate_one_in_parent(self):
|
||||
self.assertEqual(
|
||||
self.export([(0, False, {'value': 42})],
|
||||
fields=['const', 'value/value']),
|
||||
[[u'4', u'42']])
|
||||
|
||||
def test_multiple_records(self):
|
||||
self.assertEqual(
|
||||
self.export(self.commands, fields=['const', 'value/value']),
|
||||
[
|
||||
[u'4', u'4'],
|
||||
[u'', u'42'],
|
||||
[u'', u'36'],
|
||||
[u'', u'4'],
|
||||
[u'', u'13'],
|
||||
])
|
||||
|
||||
def test_multiple_records_name(self):
|
||||
self.assertEqual(
|
||||
self.export(self.commands, fields=['const', 'value']),
|
||||
[[
|
||||
u'4', u','.join(self.names)
|
||||
]])
|
||||
|
||||
def test_multiple_records_id(self):
|
||||
export = self.export(self.commands, fields=['const', 'value/.id'])
|
||||
O2M_c = self.registry('export.one2many.child')
|
||||
ids = O2M_c.browse(self.cr, openerp.SUPERUSER_ID,
|
||||
O2M_c.search(self.cr, openerp.SUPERUSER_ID, []))
|
||||
self.assertEqual(
|
||||
export,
|
||||
[
|
||||
['4', str(ids[0].id)],
|
||||
['', str(ids[1].id)],
|
||||
['', str(ids[2].id)],
|
||||
['', str(ids[3].id)],
|
||||
['', str(ids[4].id)],
|
||||
])
|
||||
|
||||
def test_multiple_records_with_name_before(self):
|
||||
self.assertEqual(
|
||||
self.export(self.commands, fields=['const', 'value', 'value/value']),
|
||||
[[ # exports sub-fields of very first o2m
|
||||
u'4', u','.join(self.names), u'4'
|
||||
]])
|
||||
|
||||
def test_multiple_records_with_name_after(self):
|
||||
self.assertEqual(
|
||||
self.export(self.commands, fields=['const', 'value/value', 'value']),
|
||||
[ # completely ignores name_get request
|
||||
[u'4', u'4', ''],
|
||||
['', u'42', ''],
|
||||
['', u'36', ''],
|
||||
['', u'4', ''],
|
||||
['', u'13', ''],
|
||||
])
|
||||
|
||||
def test_multiple_subfields_neighbour(self):
|
||||
self.assertEqual(
|
||||
self.export(self.commands, fields=['const', 'value/str','value/value']),
|
||||
[
|
||||
[u'4', u'record1', u'4'],
|
||||
['', u'record2', u'42'],
|
||||
['', u'record3', u'36'],
|
||||
['', u'record4', u'4'],
|
||||
['', u'record5', u'13'],
|
||||
])
|
||||
|
||||
def test_multiple_subfields_separated(self):
|
||||
self.assertEqual(
|
||||
self.export(self.commands, fields=['value/str', 'const', 'value/value']),
|
||||
[
|
||||
[u'record1', u'4', u'4'],
|
||||
[u'record2', '', u'42'],
|
||||
[u'record3', '', u'36'],
|
||||
[u'record4', '', u'4'],
|
||||
[u'record5', '', u'13'],
|
||||
])
|
||||
|
||||
class test_o2m_multiple(CreatorCase):
|
||||
model_name = 'export.one2many.multiple'
|
||||
|
||||
def make(self, value=None, **values):
|
||||
if value is not None: values['value'] = value
|
||||
id = self.model.create(self.cr, openerp.SUPERUSER_ID, values)
|
||||
return self.model.browse(self.cr, openerp.SUPERUSER_ID, [id])[0]
|
||||
def export(self, value=None, fields=('child1', 'child2',), context=None, **values):
|
||||
record = self.make(value, **values)
|
||||
return self.model._BaseModel__export_row(
|
||||
self.cr, openerp.SUPERUSER_ID, record,
|
||||
[f.split('/') for f in fields],
|
||||
context=context)
|
||||
|
||||
def test_empty(self):
|
||||
self.assertEqual(
|
||||
self.export(child1=False, child2=False),
|
||||
[[False, False]])
|
||||
|
||||
def test_single_per_side(self):
|
||||
self.assertEqual(
|
||||
self.export(child1=False, child2=[(0, False, {'value': 42})]),
|
||||
[[False, u'export.one2many.child.2:42']])
|
||||
|
||||
self.assertEqual(
|
||||
self.export(child1=[(0, False, {'value': 43})], child2=False),
|
||||
[[u'export.one2many.child.1:43', False]])
|
||||
|
||||
self.assertEqual(
|
||||
self.export(child1=[(0, False, {'value': 43})],
|
||||
child2=[(0, False, {'value': 42})]),
|
||||
[[u'export.one2many.child.1:43', u'export.one2many.child.2:42']])
|
||||
|
||||
def test_single_integrate_subfield(self):
|
||||
fields = ['const', 'child1/value', 'child2/value']
|
||||
self.assertEqual(
|
||||
self.export(child1=False, child2=[(0, False, {'value': 42})],
|
||||
fields=fields),
|
||||
[[u'36', False, u'42']])
|
||||
|
||||
self.assertEqual(
|
||||
self.export(child1=[(0, False, {'value': 43})], child2=False,
|
||||
fields=fields),
|
||||
[[u'36', u'43', False]])
|
||||
|
||||
self.assertEqual(
|
||||
self.export(child1=[(0, False, {'value': 43})],
|
||||
child2=[(0, False, {'value': 42})],
|
||||
fields=fields),
|
||||
[[u'36', u'43', u'42']])
|
||||
|
||||
def test_multiple(self):
|
||||
""" With two "concurrent" o2ms, exports the first line combined, then
|
||||
exports the rows for the first o2m, then the rows for the second o2m.
|
||||
"""
|
||||
fields = ['const', 'child1/value', 'child2/value']
|
||||
child1 = [(0, False, {'value': v, 'str': 'record%.02d' % index})
|
||||
for index, v in zip(itertools.count(), [4, 42, 36, 4, 13])]
|
||||
child2 = [(0, False, {'value': v, 'str': 'record%.02d' % index})
|
||||
for index, v in zip(itertools.count(10), [8, 12, 8, 55, 33, 13])]
|
||||
|
||||
self.assertEqual(
|
||||
self.export(child1=child1, child2=False, fields=fields),
|
||||
[
|
||||
[u'36', u'4', False],
|
||||
['', u'42', ''],
|
||||
['', u'36', ''],
|
||||
['', u'4', ''],
|
||||
['', u'13', ''],
|
||||
])
|
||||
self.assertEqual(
|
||||
self.export(child1=False, child2=child2, fields=fields),
|
||||
[
|
||||
[u'36', False, u'8'],
|
||||
['', '', u'12'],
|
||||
['', '', u'8'],
|
||||
['', '', u'55'],
|
||||
['', '', u'33'],
|
||||
['', '', u'13'],
|
||||
])
|
||||
self.assertEqual(
|
||||
self.export(child1=child1, child2=child2, fields=fields),
|
||||
[
|
||||
[u'36', u'4', u'8'],
|
||||
['', u'42', ''],
|
||||
['', u'36', ''],
|
||||
['', u'4', ''],
|
||||
['', u'13', ''],
|
||||
['', '', u'12'],
|
||||
['', '', u'8'],
|
||||
['', '', u'55'],
|
||||
['', '', u'33'],
|
||||
['', '', u'13'],
|
||||
])
|
||||
|
||||
class test_m2m(CreatorCase):
|
||||
model_name = 'export.many2many'
|
||||
commands = [
|
||||
(0, False, {'value': 4, 'str': 'record000'}),
|
||||
(0, False, {'value': 42, 'str': 'record001'}),
|
||||
(0, False, {'value': 36, 'str': 'record010'}),
|
||||
(0, False, {'value': 4, 'str': 'record011'}),
|
||||
(0, False, {'value': 13, 'str': 'record100'}),
|
||||
]
|
||||
names = [
|
||||
u'export.many2many.other:%d' % d['value']
|
||||
for c, _, d in commands
|
||||
]
|
||||
|
||||
def test_empty(self):
|
||||
self.assertEqual(
|
||||
self.export(False),
|
||||
[[False]])
|
||||
|
||||
def test_single(self):
|
||||
self.assertEqual(
|
||||
self.export([(0, False, {'value': 42})]),
|
||||
# name_get result
|
||||
[[u'export.many2many.other:42']])
|
||||
|
||||
def test_single_subfield(self):
|
||||
self.assertEqual(
|
||||
self.export([(0, False, {'value': 42})],
|
||||
fields=['value', 'value/value']),
|
||||
[[u'export.many2many.other:42', u'42']])
|
||||
|
||||
def test_integrate_one_in_parent(self):
|
||||
self.assertEqual(
|
||||
self.export([(0, False, {'value': 42})],
|
||||
fields=['const', 'value/value']),
|
||||
[[u'4', u'42']])
|
||||
|
||||
def test_multiple_records(self):
|
||||
self.assertEqual(
|
||||
self.export(self.commands, fields=['const', 'value/value']),
|
||||
[
|
||||
[u'4', u'4'],
|
||||
[u'', u'42'],
|
||||
[u'', u'36'],
|
||||
[u'', u'4'],
|
||||
[u'', u'13'],
|
||||
])
|
||||
|
||||
def test_multiple_records_name(self):
|
||||
self.assertEqual(
|
||||
self.export(self.commands, fields=['const', 'value']),
|
||||
[[ # FIXME: hardcoded comma, import uses config.csv_internal_sep
|
||||
# resolution: remove configurable csv_internal_sep
|
||||
u'4', u','.join(self.names)
|
||||
]])
|
||||
|
||||
# essentially same as o2m, so boring
|
||||
|
||||
class test_function(CreatorCase):
|
||||
model_name = 'export.function'
|
||||
|
||||
def test_value(self):
|
||||
""" Exports value normally returned by accessing the function field
|
||||
"""
|
||||
self.assertEqual(
|
||||
self.export(42),
|
||||
[[u'3']])
|
|
@ -0,0 +1,906 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import openerp.modules.registry
|
||||
import openerp
|
||||
|
||||
from openerp.tests import common
|
||||
|
||||
def ok(n):
|
||||
""" Successful import of ``n`` records
|
||||
|
||||
:param int n: number of records which should have been imported
|
||||
"""
|
||||
return n, 0, 0, 0
|
||||
|
||||
def error(row, message, record=None, **kwargs):
|
||||
""" Failed import of the record ``record`` at line ``row``, with the error
|
||||
message ``message``
|
||||
|
||||
:param str message:
|
||||
:param dict record:
|
||||
"""
|
||||
return (
|
||||
-1, dict(record or {}, **kwargs),
|
||||
"Line %d : %s" % (row, message),
|
||||
'')
|
||||
|
||||
def values(seq, field='value'):
|
||||
return [item[field] for item in seq]
|
||||
|
||||
class ImporterCase(common.TransactionCase):
|
||||
model_name = False
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ImporterCase, self).__init__(*args, **kwargs)
|
||||
self.model = None
|
||||
|
||||
def setUp(self):
|
||||
super(ImporterCase, self).setUp()
|
||||
self.model = self.registry(self.model_name)
|
||||
|
||||
def import_(self, fields, rows, context=None):
|
||||
return self.model.import_data(
|
||||
self.cr, openerp.SUPERUSER_ID, fields, rows, context=context)
|
||||
def read(self, fields=('value',), domain=(), context=None):
|
||||
return self.model.read(
|
||||
self.cr, openerp.SUPERUSER_ID,
|
||||
self.model.search(self.cr, openerp.SUPERUSER_ID, domain, context=context),
|
||||
fields=fields, context=context)
|
||||
def browse(self, domain=(), context=None):
|
||||
return self.model.browse(
|
||||
self.cr, openerp.SUPERUSER_ID,
|
||||
self.model.search(self.cr, openerp.SUPERUSER_ID, domain, context=context),
|
||||
context=context)
|
||||
|
||||
def xid(self, record):
|
||||
ModelData = self.registry('ir.model.data')
|
||||
|
||||
ids = ModelData.search(
|
||||
self.cr, openerp.SUPERUSER_ID,
|
||||
[('model', '=', record._table_name), ('res_id', '=', record.id)])
|
||||
if ids:
|
||||
d = ModelData.read(
|
||||
self.cr, openerp.SUPERUSER_ID, ids, ['name', 'module'])[0]
|
||||
if d['module']:
|
||||
return '%s.%s' % (d['module'], d['name'])
|
||||
return d['name']
|
||||
|
||||
name = dict(record.name_get())[record.id]
|
||||
# fix dotted name_get results, otherwise xid lookups blow up
|
||||
name = name.replace('.', '-')
|
||||
ModelData.create(self.cr, openerp.SUPERUSER_ID, {
|
||||
'name': name,
|
||||
'model': record._table_name,
|
||||
'res_id': record.id,
|
||||
'module': '__test__'
|
||||
})
|
||||
return '__test__.' + name
|
||||
|
||||
class test_ids_stuff(ImporterCase):
|
||||
model_name = 'export.integer'
|
||||
|
||||
def test_create_with_id(self):
|
||||
self.assertRaises(
|
||||
Exception, # dammit
|
||||
self.import_, ['.id', 'value'], [['42', '36']])
|
||||
def test_create_with_xid(self):
|
||||
self.assertEqual(
|
||||
self.import_(['id', 'value'], [['somexmlid', '42']]),
|
||||
ok(1))
|
||||
self.assertEqual(
|
||||
'somexmlid',
|
||||
self.xid(self.browse()[0]))
|
||||
|
||||
def test_update_with_id(self):
|
||||
id = self.model.create(self.cr, openerp.SUPERUSER_ID, {'value': 36})
|
||||
self.assertEqual(
|
||||
36,
|
||||
self.model.browse(self.cr, openerp.SUPERUSER_ID, id).value)
|
||||
|
||||
self.assertEqual(
|
||||
self.import_(['.id', 'value'], [[str(id), '42']]),
|
||||
ok(1))
|
||||
self.assertEqual(
|
||||
[42], # updated value to imported
|
||||
values(self.read()))
|
||||
|
||||
def test_update_with_xid(self):
|
||||
self.import_(['id', 'value'], [['somexmlid', '36']])
|
||||
self.assertEqual([36], values(self.read()))
|
||||
|
||||
self.import_(['id', 'value'], [['somexmlid', '1234567']])
|
||||
self.assertEqual([1234567], values(self.read()))
|
||||
|
||||
class test_boolean_field(ImporterCase):
|
||||
model_name = 'export.boolean'
|
||||
|
||||
def test_empty(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value'], []),
|
||||
ok(0))
|
||||
|
||||
def test_exported(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [
|
||||
['False'],
|
||||
['True'],
|
||||
]),
|
||||
ok(2))
|
||||
records = self.read()
|
||||
self.assertEqual([
|
||||
False,
|
||||
True,
|
||||
], values(records))
|
||||
|
||||
def test_falses(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [
|
||||
[u'0'],
|
||||
[u'off'],
|
||||
[u'false'],
|
||||
[u'FALSE'],
|
||||
[u'OFF'],
|
||||
[u''],
|
||||
]),
|
||||
ok(6))
|
||||
self.assertEqual([
|
||||
False,
|
||||
False,
|
||||
False,
|
||||
False,
|
||||
False,
|
||||
False,
|
||||
],
|
||||
values(self.read()))
|
||||
|
||||
def test_trues(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [
|
||||
['no'],
|
||||
['None'],
|
||||
['nil'],
|
||||
['()'],
|
||||
['f'],
|
||||
['#f'],
|
||||
# Problem: OpenOffice (and probably excel) output localized booleans
|
||||
['VRAI'],
|
||||
]),
|
||||
ok(7))
|
||||
self.assertEqual(
|
||||
[True] * 7,
|
||||
values(self.read()))
|
||||
|
||||
class test_integer_field(ImporterCase):
|
||||
model_name = 'export.integer'
|
||||
|
||||
def test_none(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value'], []),
|
||||
ok(0))
|
||||
|
||||
def test_empty(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [['']]),
|
||||
ok(1))
|
||||
self.assertEqual(
|
||||
[False],
|
||||
values(self.read()))
|
||||
|
||||
def test_zero(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [['0']]),
|
||||
ok(1))
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [['-0']]),
|
||||
ok(1))
|
||||
self.assertEqual([False, False], values(self.read()))
|
||||
|
||||
def test_positives(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [
|
||||
['1'],
|
||||
['42'],
|
||||
[str(2**31-1)],
|
||||
['12345678']
|
||||
]),
|
||||
ok(4))
|
||||
self.assertEqual([
|
||||
1, 42, 2**31-1, 12345678
|
||||
], values(self.read()))
|
||||
|
||||
def test_negatives(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [
|
||||
['-1'],
|
||||
['-42'],
|
||||
[str(-(2**31 - 1))],
|
||||
[str(-(2**31))],
|
||||
['-12345678']
|
||||
]),
|
||||
ok(5))
|
||||
self.assertEqual([
|
||||
-1, -42, -(2**31 - 1), -(2**31), -12345678
|
||||
], values(self.read()))
|
||||
|
||||
def test_out_of_range(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [[str(2**31)]]),
|
||||
error(1, "integer out of range\n", value=2**31))
|
||||
# auto-rollbacks if error is in process_liness, but not during
|
||||
# ir.model.data write. Can differentiate because former ends lines
|
||||
# error lines with "!"
|
||||
self.cr.rollback()
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [[str(-2**32)]]),
|
||||
error(1, "integer out of range\n", value=-2**32))
|
||||
|
||||
|
||||
def test_nonsense(self):
|
||||
# FIXME: shit error reporting, exceptions half the time, messages the other half
|
||||
self.assertRaises(
|
||||
ValueError,
|
||||
self.import_, ['value'], [['zorglub']])
|
||||
|
||||
class test_float_field(ImporterCase):
|
||||
model_name = 'export.float'
|
||||
def test_none(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value'], []),
|
||||
ok(0))
|
||||
|
||||
def test_empty(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [['']]),
|
||||
ok(1))
|
||||
self.assertEqual(
|
||||
[False],
|
||||
values(self.read()))
|
||||
|
||||
def test_zero(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [['0']]),
|
||||
ok(1))
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [['-0']]),
|
||||
ok(1))
|
||||
self.assertEqual([False, False], values(self.read()))
|
||||
|
||||
def test_positives(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [
|
||||
['1'],
|
||||
['42'],
|
||||
[str(2**31-1)],
|
||||
['12345678'],
|
||||
[str(2**33)],
|
||||
['0.000001'],
|
||||
]),
|
||||
ok(6))
|
||||
self.assertEqual([
|
||||
1, 42, 2**31-1, 12345678, 2.0**33, .000001
|
||||
], values(self.read()))
|
||||
|
||||
def test_negatives(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [
|
||||
['-1'],
|
||||
['-42'],
|
||||
[str(-2**31 + 1)],
|
||||
[str(-2**31)],
|
||||
['-12345678'],
|
||||
[str(-2**33)],
|
||||
['-0.000001'],
|
||||
]),
|
||||
ok(7))
|
||||
self.assertEqual([
|
||||
-1, -42, -(2**31 - 1), -(2**31), -12345678, -2.0**33, -.000001
|
||||
], values(self.read()))
|
||||
|
||||
def test_nonsense(self):
|
||||
self.assertRaises(
|
||||
ValueError,
|
||||
self.import_, ['value'], [['foobar']])
|
||||
|
||||
class test_string_field(ImporterCase):
|
||||
model_name = 'export.string.bounded'
|
||||
|
||||
def test_empty(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [['']]),
|
||||
ok(1))
|
||||
self.assertEqual([False], values(self.read()))
|
||||
|
||||
def test_imported(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [
|
||||
[u'foobar'],
|
||||
[u'foobarbaz'],
|
||||
[u'Með suð í eyrum við spilum endalaust'],
|
||||
[u"People 'get' types. They use them all the time. Telling "
|
||||
u"someone he can't pound a nail with a banana doesn't much "
|
||||
u"surprise him."]
|
||||
]),
|
||||
ok(4))
|
||||
self.assertEqual([
|
||||
u"foobar",
|
||||
u"foobarbaz",
|
||||
u"Með suð í eyrum ",
|
||||
u"People 'get' typ",
|
||||
], values(self.read()))
|
||||
|
||||
class test_unbound_string_field(ImporterCase):
|
||||
model_name = 'export.string'
|
||||
|
||||
def test_imported(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [
|
||||
[u'í dag viðrar vel til loftárása'],
|
||||
# ackbar.jpg
|
||||
[u"If they ask you about fun, you tell them – fun is a filthy"
|
||||
u" parasite"]
|
||||
]),
|
||||
ok(2))
|
||||
self.assertEqual([
|
||||
u"í dag viðrar vel til loftárása",
|
||||
u"If they ask you about fun, you tell them – fun is a filthy parasite"
|
||||
], values(self.read()))
|
||||
|
||||
class test_text(ImporterCase):
|
||||
model_name = 'export.text'
|
||||
|
||||
def test_empty(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [['']]),
|
||||
ok(1))
|
||||
self.assertEqual([False], values(self.read()))
|
||||
|
||||
def test_imported(self):
|
||||
s = (u"Breiðskífa er notað um útgefna hljómplötu sem inniheldur "
|
||||
u"stúdíóupptökur frá einum flytjanda. Breiðskífur eru oftast "
|
||||
u"milli 25-80 mínútur og er lengd þeirra oft miðuð við 33⅓ "
|
||||
u"snúninga 12 tommu vínylplötur (sem geta verið allt að 30 mín "
|
||||
u"hvor hlið).\n\nBreiðskífur eru stundum tvöfaldar og eru þær þá"
|
||||
u" gefnar út á tveimur geisladiskum eða tveimur vínylplötum.")
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [[s]]),
|
||||
ok(1))
|
||||
self.assertEqual([s], values(self.read()))
|
||||
|
||||
class test_selection(ImporterCase):
|
||||
model_name = 'export.selection'
|
||||
translations_fr = [
|
||||
("Qux", "toto"),
|
||||
("Bar", "titi"),
|
||||
("Foo", "tete"),
|
||||
]
|
||||
|
||||
def test_imported(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [
|
||||
['Qux'],
|
||||
['Bar'],
|
||||
['Foo'],
|
||||
['2'],
|
||||
]),
|
||||
ok(4))
|
||||
self.assertEqual([3, 2, 1, 2], values(self.read()))
|
||||
|
||||
def test_imported_translated(self):
|
||||
self.registry('res.lang').create(self.cr, openerp.SUPERUSER_ID, {
|
||||
'name': u'Français',
|
||||
'code': 'fr_FR',
|
||||
'translatable': True,
|
||||
'date_format': '%d.%m.%Y',
|
||||
'decimal_point': ',',
|
||||
'thousand_sep': ' ',
|
||||
})
|
||||
Translations = self.registry('ir.translation')
|
||||
for source, value in self.translations_fr:
|
||||
Translations.create(self.cr, openerp.SUPERUSER_ID, {
|
||||
'name': 'export.selection,value',
|
||||
'lang': 'fr_FR',
|
||||
'type': 'selection',
|
||||
'src': source,
|
||||
'value': value
|
||||
})
|
||||
|
||||
# FIXME: can't import an exported selection field label if lang != en_US
|
||||
# (see test_export.test_selection.test_localized_export)
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [
|
||||
['toto'],
|
||||
['tete'],
|
||||
['titi'],
|
||||
], context={'lang': 'fr_FR'}),
|
||||
ok(3))
|
||||
self.assertEqual([3, 1, 2], values(self.read()))
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [['Foo']], context={'lang': 'fr_FR'}),
|
||||
error(1, "Key/value 'Foo' not found in selection field 'value'",
|
||||
value=False))
|
||||
|
||||
def test_invalid(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [['Baz']]),
|
||||
error(1, "Key/value 'Baz' not found in selection field 'value'",
|
||||
# what the fuck?
|
||||
value=False))
|
||||
self.cr.rollback()
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [[42]]),
|
||||
error(1, "Key/value '42' not found in selection field 'value'",
|
||||
value=False))
|
||||
|
||||
class test_selection_function(ImporterCase):
|
||||
model_name = 'export.selection.function'
|
||||
translations_fr = [
|
||||
("Corge", "toto"),
|
||||
("Grault", "titi"),
|
||||
("Whee", "tete"),
|
||||
("Moog", "tutu"),
|
||||
]
|
||||
|
||||
def test_imported(self):
|
||||
""" import uses fields_get, so translates import label (may or may not
|
||||
be good news) *and* serializes the selection function to reverse it:
|
||||
import does not actually know that the selection field uses a function
|
||||
"""
|
||||
# NOTE: conflict between a value and a label => ?
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [
|
||||
['3'],
|
||||
["Grault"],
|
||||
]),
|
||||
ok(2))
|
||||
self.assertEqual(
|
||||
['3', '1'],
|
||||
values(self.read()))
|
||||
|
||||
def test_translated(self):
|
||||
""" Expects output of selection function returns translated labels
|
||||
"""
|
||||
self.registry('res.lang').create(self.cr, openerp.SUPERUSER_ID, {
|
||||
'name': u'Français',
|
||||
'code': 'fr_FR',
|
||||
'translatable': True,
|
||||
'date_format': '%d.%m.%Y',
|
||||
'decimal_point': ',',
|
||||
'thousand_sep': ' ',
|
||||
})
|
||||
Translations = self.registry('ir.translation')
|
||||
for source, value in self.translations_fr:
|
||||
Translations.create(self.cr, openerp.SUPERUSER_ID, {
|
||||
'name': 'export.selection,value',
|
||||
'lang': 'fr_FR',
|
||||
'type': 'selection',
|
||||
'src': source,
|
||||
'value': value
|
||||
})
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [
|
||||
['toto'],
|
||||
['tete'],
|
||||
], context={'lang': 'fr_FR'}),
|
||||
error(1, "Key/value 'toto' not found in selection field 'value'",
|
||||
value=False))
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [['Wheee']], context={'lang': 'fr_FR'}),
|
||||
ok(1))
|
||||
|
||||
class test_m2o(ImporterCase):
|
||||
model_name = 'export.many2one'
|
||||
|
||||
def test_by_name(self):
|
||||
# create integer objects
|
||||
integer_id1 = self.registry('export.integer').create(
|
||||
self.cr, openerp.SUPERUSER_ID, {'value': 42})
|
||||
integer_id2 = self.registry('export.integer').create(
|
||||
self.cr, openerp.SUPERUSER_ID, {'value': 36})
|
||||
# get its name
|
||||
name1 = dict(self.registry('export.integer').name_get(
|
||||
self.cr, openerp.SUPERUSER_ID,[integer_id1]))[integer_id1]
|
||||
name2 = dict(self.registry('export.integer').name_get(
|
||||
self.cr, openerp.SUPERUSER_ID,[integer_id2]))[integer_id2]
|
||||
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [
|
||||
# import by name_get
|
||||
[name1],
|
||||
[name1],
|
||||
[name2],
|
||||
]),
|
||||
ok(3))
|
||||
# correct ids assigned to corresponding records
|
||||
self.assertEqual([
|
||||
(integer_id1, name1),
|
||||
(integer_id1, name1),
|
||||
(integer_id2, name2),],
|
||||
values(self.read()))
|
||||
|
||||
def test_by_xid(self):
|
||||
ExportInteger = self.registry('export.integer')
|
||||
integer_id = ExportInteger.create(
|
||||
self.cr, openerp.SUPERUSER_ID, {'value': 42})
|
||||
xid = self.xid(ExportInteger.browse(
|
||||
self.cr, openerp.SUPERUSER_ID, [integer_id])[0])
|
||||
|
||||
self.assertEqual(
|
||||
self.import_(['value/id'], [[xid]]),
|
||||
ok(1))
|
||||
b = self.browse()
|
||||
self.assertEqual(42, b[0].value.value)
|
||||
|
||||
def test_by_id(self):
|
||||
integer_id = self.registry('export.integer').create(
|
||||
self.cr, openerp.SUPERUSER_ID, {'value': 42})
|
||||
self.assertEqual(
|
||||
self.import_(['value/.id'], [[integer_id]]),
|
||||
ok(1))
|
||||
b = self.browse()
|
||||
self.assertEqual(42, b[0].value.value)
|
||||
|
||||
def test_by_names(self):
|
||||
integer_id1 = self.registry('export.integer').create(
|
||||
self.cr, openerp.SUPERUSER_ID, {'value': 42})
|
||||
integer_id2 = self.registry('export.integer').create(
|
||||
self.cr, openerp.SUPERUSER_ID, {'value': 42})
|
||||
name1 = dict(self.registry('export.integer').name_get(
|
||||
self.cr, openerp.SUPERUSER_ID,[integer_id1]))[integer_id1]
|
||||
name2 = dict(self.registry('export.integer').name_get(
|
||||
self.cr, openerp.SUPERUSER_ID,[integer_id2]))[integer_id2]
|
||||
# names should be the same
|
||||
self.assertEqual(name1, name2)
|
||||
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [[name2]]),
|
||||
ok(1))
|
||||
# FIXME: is it really normal import does not care for name_search collisions?
|
||||
self.assertEqual([
|
||||
(integer_id1, name1)
|
||||
], values(self.read()))
|
||||
|
||||
def test_fail_by_implicit_id(self):
|
||||
""" Can't implicitly import records by id
|
||||
"""
|
||||
# create integer objects
|
||||
integer_id1 = self.registry('export.integer').create(
|
||||
self.cr, openerp.SUPERUSER_ID, {'value': 42})
|
||||
integer_id2 = self.registry('export.integer').create(
|
||||
self.cr, openerp.SUPERUSER_ID, {'value': 36})
|
||||
|
||||
self.assertRaises(
|
||||
ValueError, # Because name_search all the things. Fallback schmallback
|
||||
self.import_, ['value'], [
|
||||
# import by id, without specifying it
|
||||
[integer_id1],
|
||||
[integer_id2],
|
||||
[integer_id1],
|
||||
])
|
||||
|
||||
def test_sub_field(self):
|
||||
""" Does not implicitly create the record, does not warn that you can't
|
||||
import m2o subfields (at all)...
|
||||
"""
|
||||
self.assertRaises(
|
||||
ValueError, # No record found for 42, name_searches the bloody thing
|
||||
self.import_, ['value/value'], [['42']])
|
||||
|
||||
def test_fail_noids(self):
|
||||
self.assertRaises(
|
||||
ValueError,
|
||||
self.import_, ['value'], [['nameisnoexist:3']])
|
||||
self.cr.rollback()
|
||||
self.assertRaises(
|
||||
ValueError,
|
||||
self.import_, ['value/id'], [['noxidhere']]),
|
||||
self.cr.rollback()
|
||||
self.assertRaises(
|
||||
Exception, # FIXME: Why can't you be a ValueError like everybody else?
|
||||
self.import_, ['value/.id'], [[66]])
|
||||
|
||||
class test_m2m(ImporterCase):
|
||||
model_name = 'export.many2many'
|
||||
|
||||
# apparently, one and only thing which works is a
|
||||
# csv_internal_sep-separated list of ids, xids, or names (depending if
|
||||
# m2m/.id, m2m/id or m2m[/anythingelse]
|
||||
def test_ids(self):
|
||||
id1 = self.registry('export.many2many.other').create(
|
||||
self.cr, openerp.SUPERUSER_ID, {'value': 3, 'str': 'record0'})
|
||||
id2 = self.registry('export.many2many.other').create(
|
||||
self.cr, openerp.SUPERUSER_ID, {'value': 44, 'str': 'record1'})
|
||||
id3 = self.registry('export.many2many.other').create(
|
||||
self.cr, openerp.SUPERUSER_ID, {'value': 84, 'str': 'record2'})
|
||||
id4 = self.registry('export.many2many.other').create(
|
||||
self.cr, openerp.SUPERUSER_ID, {'value': 9, 'str': 'record3'})
|
||||
id5 = self.registry('export.many2many.other').create(
|
||||
self.cr, openerp.SUPERUSER_ID, {'value': 99, 'str': 'record4'})
|
||||
|
||||
self.assertEqual(
|
||||
self.import_(['value/.id'], [
|
||||
['%d,%d' % (id1, id2)],
|
||||
['%d,%d,%d' % (id1, id3, id4)],
|
||||
['%d,%d,%d' % (id1, id2, id3)],
|
||||
['%d' % id5]
|
||||
]),
|
||||
ok(4))
|
||||
ids = lambda records: [record.id for record in records]
|
||||
|
||||
b = self.browse()
|
||||
self.assertEqual(ids(b[0].value), [id1, id2])
|
||||
self.assertEqual(values(b[0].value), [3, 44])
|
||||
|
||||
self.assertEqual(ids(b[2].value), [id1, id2, id3])
|
||||
self.assertEqual(values(b[2].value), [3, 44, 84])
|
||||
|
||||
def test_noids(self):
|
||||
try:
|
||||
self.import_(['value/.id'], [['42']])
|
||||
self.fail("Should have raised an exception")
|
||||
except Exception, e:
|
||||
self.assertIs(type(e), Exception,
|
||||
"test should be fixed on exception subclass")
|
||||
|
||||
def test_xids(self):
|
||||
M2O_o = self.registry('export.many2many.other')
|
||||
id1 = M2O_o.create(self.cr, openerp.SUPERUSER_ID, {'value': 3, 'str': 'record0'})
|
||||
id2 = M2O_o.create(self.cr, openerp.SUPERUSER_ID, {'value': 44, 'str': 'record1'})
|
||||
id3 = M2O_o.create(self.cr, openerp.SUPERUSER_ID, {'value': 84, 'str': 'record2'})
|
||||
id4 = M2O_o.create(self.cr, openerp.SUPERUSER_ID, {'value': 9, 'str': 'record3'})
|
||||
records = M2O_o.browse(self.cr, openerp.SUPERUSER_ID, [id1, id2, id3, id4])
|
||||
|
||||
self.assertEqual(
|
||||
self.import_(['value/id'], [
|
||||
['%s,%s' % (self.xid(records[0]), self.xid(records[1]))],
|
||||
['%s' % self.xid(records[3])],
|
||||
['%s,%s' % (self.xid(records[2]), self.xid(records[1]))],
|
||||
]),
|
||||
ok(3))
|
||||
|
||||
b = self.browse()
|
||||
self.assertEqual(values(b[0].value), [3, 44])
|
||||
self.assertEqual(values(b[2].value), [44, 84])
|
||||
def test_noxids(self):
|
||||
self.assertRaises(
|
||||
ValueError,
|
||||
self.import_, ['value/id'], [['noxidforthat']])
|
||||
|
||||
def test_names(self):
|
||||
M2O_o = self.registry('export.many2many.other')
|
||||
id1 = M2O_o.create(self.cr, openerp.SUPERUSER_ID, {'value': 3, 'str': 'record0'})
|
||||
id2 = M2O_o.create(self.cr, openerp.SUPERUSER_ID, {'value': 44, 'str': 'record1'})
|
||||
id3 = M2O_o.create(self.cr, openerp.SUPERUSER_ID, {'value': 84, 'str': 'record2'})
|
||||
id4 = M2O_o.create(self.cr, openerp.SUPERUSER_ID, {'value': 9, 'str': 'record3'})
|
||||
records = M2O_o.browse(self.cr, openerp.SUPERUSER_ID, [id1, id2, id3, id4])
|
||||
|
||||
name = lambda record: dict(record.name_get())[record.id]
|
||||
|
||||
self.assertEqual(
|
||||
self.import_(['value'], [
|
||||
['%s,%s' % (name(records[1]), name(records[2]))],
|
||||
['%s,%s,%s' % (name(records[0]), name(records[1]), name(records[2]))],
|
||||
['%s,%s' % (name(records[0]), name(records[3]))],
|
||||
]),
|
||||
ok(3))
|
||||
|
||||
b = self.browse()
|
||||
self.assertEqual(values(b[1].value), [3, 44, 84])
|
||||
self.assertEqual(values(b[2].value), [3, 9])
|
||||
|
||||
def test_nonames(self):
|
||||
self.assertRaises(
|
||||
ValueError,
|
||||
self.import_, ['value'], [['wherethem2mhavenonames']])
|
||||
|
||||
def test_import_to_existing(self):
|
||||
M2O_o = self.registry('export.many2many.other')
|
||||
id1 = M2O_o.create(self.cr, openerp.SUPERUSER_ID, {'value': 3, 'str': 'record0'})
|
||||
id2 = M2O_o.create(self.cr, openerp.SUPERUSER_ID, {'value': 44, 'str': 'record1'})
|
||||
id3 = M2O_o.create(self.cr, openerp.SUPERUSER_ID, {'value': 84, 'str': 'record2'})
|
||||
id4 = M2O_o.create(self.cr, openerp.SUPERUSER_ID, {'value': 9, 'str': 'record3'})
|
||||
|
||||
xid = 'myxid'
|
||||
self.assertEqual(
|
||||
self.import_(['id', 'value/.id'], [[xid, '%d,%d' % (id1, id2)]]),
|
||||
ok(1))
|
||||
self.assertEqual(
|
||||
self.import_(['id', 'value/.id'], [[xid, '%d,%d' % (id3, id4)]]),
|
||||
ok(1))
|
||||
|
||||
b = self.browse()
|
||||
self.assertEqual(len(b), 1)
|
||||
# TODO: replacement of existing m2m values is correct?
|
||||
self.assertEqual(values(b[0].value), [84, 9])
|
||||
|
||||
class test_o2m(ImporterCase):
|
||||
model_name = 'export.one2many'
|
||||
|
||||
def test_single(self):
|
||||
self.assertEqual(
|
||||
self.import_(['const', 'value/value'], [
|
||||
['5', '63']
|
||||
]),
|
||||
ok(1))
|
||||
|
||||
(b,) = self.browse()
|
||||
self.assertEqual(b.const, 5)
|
||||
self.assertEqual(values(b.value), [63])
|
||||
|
||||
def test_multicore(self):
|
||||
self.assertEqual(
|
||||
self.import_(['const', 'value/value'], [
|
||||
['5', '63'],
|
||||
['6', '64'],
|
||||
]),
|
||||
ok(2))
|
||||
|
||||
b1, b2 = self.browse()
|
||||
self.assertEqual(b1.const, 5)
|
||||
self.assertEqual(values(b1.value), [63])
|
||||
self.assertEqual(b2.const, 6)
|
||||
self.assertEqual(values(b2.value), [64])
|
||||
|
||||
def test_multisub(self):
|
||||
self.assertEqual(
|
||||
self.import_(['const', 'value/value'], [
|
||||
['5', '63'],
|
||||
['', '64'],
|
||||
['', '65'],
|
||||
['', '66'],
|
||||
]),
|
||||
ok(4))
|
||||
|
||||
(b,) = self.browse()
|
||||
self.assertEqual(values(b.value), [63, 64, 65, 66])
|
||||
|
||||
def test_multi_subfields(self):
|
||||
self.assertEqual(
|
||||
self.import_(['value/str', 'const', 'value/value'], [
|
||||
['this', '5', '63'],
|
||||
['is', '', '64'],
|
||||
['the', '', '65'],
|
||||
['rhythm', '', '66'],
|
||||
]),
|
||||
ok(4))
|
||||
|
||||
(b,) = self.browse()
|
||||
self.assertEqual(values(b.value), [63, 64, 65, 66])
|
||||
self.assertEqual(
|
||||
values(b.value, 'str'),
|
||||
'this is the rhythm'.split())
|
||||
|
||||
def test_link_inline(self):
|
||||
id1 = self.registry('export.one2many.child').create(self.cr, openerp.SUPERUSER_ID, {
|
||||
'str': 'Bf', 'value': 109
|
||||
})
|
||||
id2 = self.registry('export.one2many.child').create(self.cr, openerp.SUPERUSER_ID, {
|
||||
'str': 'Me', 'value': 262
|
||||
})
|
||||
|
||||
try:
|
||||
self.import_(['const', 'value/.id'], [
|
||||
['42', '%d,%d' % (id1, id2)]
|
||||
])
|
||||
except ValueError, e:
|
||||
# should be Exception(Database ID doesn't exist: export.one2many.child : $id1,$id2)
|
||||
self.assertIs(type(e), ValueError)
|
||||
self.assertEqual(
|
||||
e.args[0],
|
||||
"invalid literal for int() with base 10: '%d,%d'" % (id1, id2))
|
||||
|
||||
def test_link(self):
|
||||
id1 = self.registry('export.one2many.child').create(self.cr, openerp.SUPERUSER_ID, {
|
||||
'str': 'Bf', 'value': 109
|
||||
})
|
||||
id2 = self.registry('export.one2many.child').create(self.cr, openerp.SUPERUSER_ID, {
|
||||
'str': 'Me', 'value': 262
|
||||
})
|
||||
|
||||
self.assertEqual(
|
||||
self.import_(['const', 'value/.id'], [
|
||||
['42', str(id1)],
|
||||
['', str(id2)],
|
||||
]),
|
||||
ok(2))
|
||||
|
||||
# No record values alongside id => o2m resolution skipped altogether,
|
||||
# creates 2 records => remove/don't import columns sideshow columns,
|
||||
# get completely different semantics
|
||||
b, b1 = self.browse()
|
||||
self.assertEqual(b.const, 42)
|
||||
self.assertEqual(values(b.value), [])
|
||||
self.assertEqual(b1.const, 4)
|
||||
self.assertEqual(values(b1.value), [])
|
||||
|
||||
def test_link_2(self):
|
||||
O2M_c = self.registry('export.one2many.child')
|
||||
id1 = O2M_c.create(self.cr, openerp.SUPERUSER_ID, {
|
||||
'str': 'Bf', 'value': 109
|
||||
})
|
||||
id2 = O2M_c.create(self.cr, openerp.SUPERUSER_ID, {
|
||||
'str': 'Me', 'value': 262
|
||||
})
|
||||
|
||||
self.assertEqual(
|
||||
self.import_(['const', 'value/.id', 'value/value'], [
|
||||
['42', str(id1), '1'],
|
||||
['', str(id2), '2'],
|
||||
]),
|
||||
ok(2))
|
||||
|
||||
(b,) = self.browse()
|
||||
# if an id (db or xid) is provided, expectations that objects are
|
||||
# *already* linked and emits UPDATE (1, id, {}).
|
||||
# Noid => CREATE (0, ?, {})
|
||||
# TODO: xid ignored aside from getting corresponding db id?
|
||||
self.assertEqual(b.const, 42)
|
||||
self.assertEqual(values(b.value), [])
|
||||
|
||||
# FIXME: updates somebody else's records?
|
||||
self.assertEqual(
|
||||
O2M_c.read(self.cr, openerp.SUPERUSER_ID, id1),
|
||||
{'id': id1, 'str': 'Bf', 'value': 1, 'parent_id': False})
|
||||
self.assertEqual(
|
||||
O2M_c.read(self.cr, openerp.SUPERUSER_ID, id2),
|
||||
{'id': id2, 'str': 'Me', 'value': 2, 'parent_id': False})
|
||||
|
||||
class test_o2m_multiple(ImporterCase):
|
||||
model_name = 'export.one2many.multiple'
|
||||
|
||||
def test_multi_mixed(self):
|
||||
self.assertEqual(
|
||||
self.import_(['const', 'child1/value', 'child2/value'], [
|
||||
['5', '11', '21'],
|
||||
['', '12', '22'],
|
||||
['', '13', '23'],
|
||||
['', '14', ''],
|
||||
]),
|
||||
ok(4))
|
||||
# Oh yeah, that's the stuff
|
||||
(b, b1, b2) = self.browse()
|
||||
self.assertEqual(values(b.child1), [11])
|
||||
self.assertEqual(values(b.child2), [21])
|
||||
|
||||
self.assertEqual(values(b1.child1), [12])
|
||||
self.assertEqual(values(b1.child2), [22])
|
||||
|
||||
self.assertEqual(values(b2.child1), [13, 14])
|
||||
self.assertEqual(values(b2.child2), [23])
|
||||
|
||||
def test_multi(self):
|
||||
self.assertEqual(
|
||||
self.import_(['const', 'child1/value', 'child2/value'], [
|
||||
['5', '11', '21'],
|
||||
['', '12', ''],
|
||||
['', '13', ''],
|
||||
['', '14', ''],
|
||||
['', '', '22'],
|
||||
['', '', '23'],
|
||||
]),
|
||||
ok(6))
|
||||
# What the actual fuck?
|
||||
(b, b1) = self.browse()
|
||||
self.assertEqual(values(b.child1), [11, 12, 13, 14])
|
||||
self.assertEqual(values(b.child2), [21])
|
||||
self.assertEqual(values(b1.child2), [22, 23])
|
||||
|
||||
def test_multi_fullsplit(self):
|
||||
self.assertEqual(
|
||||
self.import_(['const', 'child1/value', 'child2/value'], [
|
||||
['5', '11', ''],
|
||||
['', '12', ''],
|
||||
['', '13', ''],
|
||||
['', '14', ''],
|
||||
['', '', '21'],
|
||||
['', '', '22'],
|
||||
['', '', '23'],
|
||||
]),
|
||||
ok(7))
|
||||
# oh wow
|
||||
(b, b1) = self.browse()
|
||||
self.assertEqual(b.const, 5)
|
||||
self.assertEqual(values(b.child1), [11, 12, 13, 14])
|
||||
self.assertEqual(b1.const, 36)
|
||||
self.assertEqual(values(b1.child2), [21, 22, 23])
|
||||
|
||||
# function, related, reference: written to db as-is...
|
||||
# => function uses @type for value coercion/conversion
|
|
@ -39,13 +39,16 @@ class TransactionCase(unittest2.TestCase):
|
|||
"""
|
||||
|
||||
def setUp(self):
|
||||
self.cr = openerp.modules.registry.RegistryManager.get(DB).db.cursor()
|
||||
self.cr = self.cursor()
|
||||
self.uid = openerp.SUPERUSER_ID
|
||||
|
||||
def tearDown(self):
|
||||
self.cr.rollback()
|
||||
self.cr.close()
|
||||
|
||||
def cursor(self):
|
||||
return openerp.modules.registry.RegistryManager.get(DB).db.cursor()
|
||||
|
||||
def registry(self, model):
|
||||
return openerp.modules.registry.RegistryManager.get(DB)[model]
|
||||
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
import unittest
|
||||
from openerp.tools.html_sanitize import html_sanitize
|
||||
|
||||
test_case = """
|
||||
<font size="2" style="color: rgb(31, 31, 31); font-family: monospace; font-variant: normal; line-height: normal; ">test1</font>
|
||||
<div style="color: rgb(31, 31, 31); font-family: monospace; font-variant: normal; line-height: normal; font-size: 12px; font-style: normal; ">
|
||||
<b>test2</b></div><div style="color: rgb(31, 31, 31); font-family: monospace; font-variant: normal; line-height: normal; font-size: 12px; ">
|
||||
<i>test3</i></div><div style="color: rgb(31, 31, 31); font-family: monospace; font-variant: normal; line-height: normal; font-size: 12px; ">
|
||||
<u>test4</u></div><div style="color: rgb(31, 31, 31); font-family: monospace; font-variant: normal; line-height: normal; font-size: 12px; ">
|
||||
<strike>test5</strike></div><div style="color: rgb(31, 31, 31); font-family: monospace; font-variant: normal; line-height: normal; ">
|
||||
<font size="5">test6</font></div><div><ul><li><font color="#1f1f1f" face="monospace" size="2">test7</font></li><li>
|
||||
<font color="#1f1f1f" face="monospace" size="2">test8</font></li></ul><div><ol><li><font color="#1f1f1f" face="monospace" size="2">test9</font>
|
||||
</li><li><font color="#1f1f1f" face="monospace" size="2">test10</font></li></ol></div></div>
|
||||
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><div><font color="#1f1f1f" face="monospace" size="2">
|
||||
test11</font></div></div></div></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
|
||||
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><font color="#1f1f1f" face="monospace" size="2">
|
||||
test12</font></div><div><font color="#1f1f1f" face="monospace" size="2"><br></font></div></blockquote></blockquote>
|
||||
<font color="#1f1f1f" face="monospace" size="2"><a href="http://google.com">google</a></font>
|
||||
<a href="javascript:alert('malicious code')">test link</a>
|
||||
"""
|
||||
|
||||
class TestSanitizer(unittest.TestCase):
|
||||
|
||||
def test_simple(self):
|
||||
x = "yop"
|
||||
self.assertEqual(x, html_sanitize(x))
|
||||
|
||||
def test_test_case(self):
|
||||
html_sanitize(test_case)
|
||||
|
||||
def test_crm(self):
|
||||
html_sanitize("Merci à l'intérêt pour notre produit.nous vous contacterons bientôt. Merci")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -0,0 +1,131 @@
|
|||
# This test can be run stand-alone with something like:
|
||||
# > PYTHONPATH=. python2 openerp/tests/test_view_validation.py
|
||||
|
||||
from lxml import etree
|
||||
from StringIO import StringIO
|
||||
import unittest2
|
||||
|
||||
import openerp
|
||||
from openerp.tools.view_validation import *
|
||||
|
||||
invalid_form = etree.parse(StringIO('''\
|
||||
<form>
|
||||
<label></label>
|
||||
<group>
|
||||
<div>
|
||||
<page></page>
|
||||
<label colspan="True"></label>
|
||||
<field></field>
|
||||
</div>
|
||||
</group>
|
||||
<notebook>
|
||||
<page>
|
||||
<group col="Two">
|
||||
<div>
|
||||
<label></label>
|
||||
<field colspan="Five"> </field>
|
||||
</div>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
''')).getroot()
|
||||
|
||||
valid_form = etree.parse(StringIO('''\
|
||||
<form string="">
|
||||
<field name=""></field>
|
||||
<field name=""></field>
|
||||
<notebook>
|
||||
<page>
|
||||
<field name=""></field>
|
||||
<label string=""></label>
|
||||
<field name=""></field>
|
||||
</page>
|
||||
<page>
|
||||
<group colspan="5" col="2">
|
||||
<label for=""></label>
|
||||
<label string="" colspan="5"></label>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
''')).getroot()
|
||||
|
||||
invalid_graph = etree.parse(StringIO('''\
|
||||
<graph>
|
||||
<label/>
|
||||
<group>
|
||||
<div>
|
||||
<field></field>
|
||||
<field></field>
|
||||
</div>
|
||||
</group>
|
||||
</graph>
|
||||
''')).getroot()
|
||||
|
||||
valid_graph = etree.parse(StringIO('''\
|
||||
<graph string="">
|
||||
<field name=""></field>
|
||||
<field name=""></field>
|
||||
</graph>
|
||||
''')).getroot()
|
||||
|
||||
invalid_tree = etree.parse(StringIO('''\
|
||||
<tree>
|
||||
<group>
|
||||
<div>
|
||||
<field></field>
|
||||
<field></field>
|
||||
</div>
|
||||
</group>
|
||||
</tree>
|
||||
''')).getroot()
|
||||
|
||||
valid_tree= etree.parse(StringIO('''\
|
||||
<tree string="">
|
||||
<field name=""></field>
|
||||
<field name=""></field>
|
||||
<button/>
|
||||
<field name=""></field>
|
||||
</tree>
|
||||
''')).getroot()
|
||||
|
||||
|
||||
class test_view_validation(unittest2.TestCase):
|
||||
""" Test the view validation code (but not the views themselves). """
|
||||
|
||||
def test_page_validation(self):
|
||||
assert not valid_page_in_book(invalid_form)
|
||||
assert valid_page_in_book(valid_form)
|
||||
|
||||
def test_all_field_validation(self):
|
||||
assert not valid_att_in_field(invalid_form)
|
||||
assert valid_att_in_field(valid_form)
|
||||
|
||||
def test_all_label_validation(self):
|
||||
assert not valid_att_in_label(invalid_form)
|
||||
assert valid_att_in_label(valid_form)
|
||||
|
||||
def test_form_string_validation(self):
|
||||
assert not valid_att_in_form(invalid_form)
|
||||
assert valid_att_in_form(valid_form)
|
||||
|
||||
def test_graph_validation(self):
|
||||
assert not valid_field_in_graph(invalid_graph)
|
||||
assert valid_field_in_graph(valid_graph)
|
||||
|
||||
def test_tree_validation(self):
|
||||
assert not valid_field_in_tree(invalid_tree)
|
||||
assert valid_field_in_tree(valid_tree)
|
||||
|
||||
def test_colspan_datatype_validation(self):
|
||||
assert not valid_type_in_colspan(invalid_form)
|
||||
assert valid_type_in_colspan(valid_form)
|
||||
|
||||
def test_col_datatype_validation(self):
|
||||
assert not valid_type_in_col(invalid_form)
|
||||
assert valid_type_in_col(valid_form)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest2.main()
|
|
@ -33,6 +33,7 @@ from pdf_utils import *
|
|||
from yaml_import import *
|
||||
from sql import *
|
||||
from float_utils import *
|
||||
from html_sanitize import *
|
||||
|
||||
#.apidoc title: Tools
|
||||
|
||||
|
|
|
@ -596,7 +596,9 @@ form: module.record_id""" % (xml_id,)
|
|||
"act_window": 'STOCK_NEW',
|
||||
"report.xml": 'STOCK_PASTE',
|
||||
"wizard": 'STOCK_EXECUTE',
|
||||
"url": 'STOCK_JUMP_TO'
|
||||
"url": 'STOCK_JUMP_TO',
|
||||
"client": 'STOCK_EXECUTE',
|
||||
"server": 'STOCK_EXECUTE',
|
||||
}
|
||||
values['icon'] = icons.get(a_type,'STOCK_NEW')
|
||||
if a_type=='act_window':
|
||||
|
@ -607,8 +609,9 @@ form: module.record_id""" % (xml_id,)
|
|||
"Verify that this is a window action or add a type argument." % (a_action,)
|
||||
action_type,action_mode,action_name,view_id,target = rrres
|
||||
if view_id:
|
||||
cr.execute('SELECT type FROM ir_ui_view WHERE id=%s', (int(view_id),))
|
||||
action_mode, = cr.fetchone()
|
||||
cr.execute('SELECT arch FROM ir_ui_view WHERE id=%s', (int(view_id),))
|
||||
arch, = cr.fetchone()
|
||||
action_mode = etree.fromstring(arch.encode('utf8')).tag
|
||||
cr.execute('SELECT view_mode FROM ir_act_window_view WHERE act_window_id=%s ORDER BY sequence LIMIT 1', (int(a_id),))
|
||||
if cr.rowcount:
|
||||
action_mode, = cr.fetchone()
|
||||
|
@ -624,18 +627,19 @@ form: module.record_id""" % (xml_id,)
|
|||
values['icon'] = 'STOCK_EXECUTE'
|
||||
if not values.get('name', False):
|
||||
values['name'] = action_name
|
||||
elif a_type=='wizard':
|
||||
|
||||
elif a_type in ['wizard', 'url', 'client', 'server'] and not values.get('name'):
|
||||
a_id = self.id_get(cr, a_action)
|
||||
cr.execute('select name from ir_act_wizard where id=%s', (int(a_id),))
|
||||
a_table = 'ir_act_%s' % a_type
|
||||
cr.execute('select name from %s where id=%%s' % a_table, (int(a_id),))
|
||||
resw = cr.fetchone()
|
||||
if (not values.get('name', False)) and resw:
|
||||
values['name'] = resw[0]
|
||||
elif a_type=='url':
|
||||
a_id = self.id_get(cr, a_action)
|
||||
cr.execute('select name from ir_act_url where id=%s', (int(a_id),))
|
||||
resw = cr.fetchone()
|
||||
if (not values.get('name')) and resw:
|
||||
if resw:
|
||||
values['name'] = resw[0]
|
||||
|
||||
if not values.get('name'):
|
||||
# ensure menu has a name
|
||||
values['name'] = rec_id or '?'
|
||||
|
||||
if rec.get('sequence'):
|
||||
values['sequence'] = int(rec.get('sequence'))
|
||||
if rec.get('icon'):
|
||||
|
@ -657,9 +661,7 @@ form: module.record_id""" % (xml_id,)
|
|||
groups_value.append((4, group_id))
|
||||
values['groups_id'] = groups_value
|
||||
|
||||
xml_id = rec.get('id','').encode('utf8')
|
||||
self._test_xml_id(xml_id)
|
||||
pid = self.pool.get('ir.model.data')._update(cr, self.uid, 'ir.ui.menu', self.module, values, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode, res_id=res and res[0] or False)
|
||||
pid = self.pool.get('ir.model.data')._update(cr, self.uid, 'ir.ui.menu', self.module, values, rec_id, noupdate=self.isnoupdate(data_node), mode=self.mode, res_id=res and res[0] or False)
|
||||
|
||||
if rec_id and pid:
|
||||
self.idref[rec_id] = int(pid)
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
|
||||
import re
|
||||
|
||||
def html_sanitize(x):
|
||||
return x # It seems that our test suite doesn't care.
|
||||
if not x:
|
||||
return x
|
||||
root = pq("<div />")
|
||||
if type(x) == str:
|
||||
x = unicode(x, "utf8", "replace")
|
||||
root.html(x)
|
||||
result = handle_element(root[0])
|
||||
new = pq(result)
|
||||
return new.html()
|
||||
|
||||
to_remove = set(["script", "head", "meta", "title", "link", "img"])
|
||||
to_unwrap = set(["html", "body"])
|
||||
|
||||
javascript_regex = re.compile("""^\s*javascript\s*\:.*$""")
|
||||
def handle_a(el, new):
|
||||
href = el.get("href", "#")
|
||||
if javascript_regex.search(href):
|
||||
href = "#"
|
||||
new.set("href", href)
|
||||
special = {
|
||||
"a": handle_a,
|
||||
}
|
||||
|
||||
def handle_element(el):
|
||||
if type(el) == str or type(el) == unicode:
|
||||
return [el]
|
||||
if el.tag in to_remove:
|
||||
return []
|
||||
if el.tag in to_unwrap:
|
||||
return reduce(lambda x,y: x+y, [handle_element(x) for x in children(el)])
|
||||
new = pq("<%s />" % el.tag)[0]
|
||||
for i in children(el):
|
||||
append_to(handle_element(i), new)
|
||||
if el.tag in special:
|
||||
special[el.tag](el, new)
|
||||
return [new]
|
||||
|
||||
def children(el):
|
||||
res = []
|
||||
if el.text is not None:
|
||||
res.append(el.text)
|
||||
for i in el.getchildren():
|
||||
res.append(i)
|
||||
if i.tail is not None:
|
||||
res.append(i.tail)
|
||||
return res
|
||||
|
||||
def append_to(new_ones, el):
|
||||
for i in new_ones:
|
||||
if type(i) == str or type(i) == unicode:
|
||||
children = el.getchildren()
|
||||
if len(children) == 0:
|
||||
el.text = i
|
||||
else:
|
||||
children[-1].tail = i
|
||||
else:
|
||||
el.append(i)
|
|
@ -0,0 +1,85 @@
|
|||
""" View validation code (using assertions, not the RNG schema). """
|
||||
|
||||
import logging
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def valid_page_in_book(arch):
|
||||
"""A `page` node must be below a `book` node."""
|
||||
return not arch.xpath('//page[not(ancestor::notebook)]')
|
||||
|
||||
|
||||
def valid_field_in_graph(arch):
|
||||
"""A `graph` must have `string` attribute and an immediate node of `graph` view must be `field`."""
|
||||
if arch.xpath('//graph[not (@string)]'):
|
||||
return False
|
||||
for child in arch.xpath('/graph/child::*'):
|
||||
if child.tag != 'field':
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def valid_field_in_tree(arch):
|
||||
"""A `tree` must have `string` attribute and an immediate node of `tree` view must be `field` or `button`."""
|
||||
if arch.xpath('//tree[not (@string)]'):
|
||||
return False
|
||||
for child in arch.xpath('/tree/child::*'):
|
||||
if child.tag not in ('field', 'button'):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def valid_att_in_field(arch):
|
||||
"""A `name` attribute must be in a `field` node."""
|
||||
return not arch.xpath('//field[not (@name)]')
|
||||
|
||||
|
||||
def valid_att_in_label(arch):
|
||||
"""A `for` and `string` attribute must be on a `label` node."""
|
||||
return not arch.xpath('//label[not ((@for) or (@string))]')
|
||||
|
||||
|
||||
def valid_att_in_form(arch):
|
||||
"""A `string` attribute must be on a `form` node."""
|
||||
return not arch.xpath('//form[not (@string)]')
|
||||
|
||||
|
||||
def valid_type_in_colspan(arch):
|
||||
"""A `colspan` attribute must be an `integer` type."""
|
||||
for attrib in arch.xpath('//*/@colspan'):
|
||||
try:
|
||||
int(attrib)
|
||||
except:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def valid_type_in_col(arch):
|
||||
"""A `col` attribute must be an `integer` type."""
|
||||
for attrib in arch.xpath('//*/@col'):
|
||||
try:
|
||||
int(attrib)
|
||||
except:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def valid_view(arch):
|
||||
if arch.tag == 'form':
|
||||
for pred in [valid_page_in_book, valid_att_in_form, valid_type_in_colspan,\
|
||||
valid_type_in_col, valid_att_in_field, valid_att_in_label]:
|
||||
if not pred(arch):
|
||||
_logger.error('Invalid XML: %s', pred.__doc__)
|
||||
return False
|
||||
elif arch.tag == 'graph':
|
||||
for pred in [valid_field_in_graph, valid_att_in_field]:
|
||||
if not pred(arch):
|
||||
_logger.error('Invalid XML: %s', pred.__doc__)
|
||||
return False
|
||||
elif arch.tag == 'tree':
|
||||
for pred in [valid_field_in_tree, valid_att_in_field]:
|
||||
if not pred(arch):
|
||||
_logger.error('Invalid XML: %s', pred.__doc__)
|
||||
return False
|
||||
return True
|
Loading…
Reference in New Issue