[MERGE] trunk

bzr revid: al@openerp.com-20111001012210-uqqso9y80a21hgeo
This commit is contained in:
Antony Lesuisse 2011-10-01 03:22:10 +02:00
commit ace4703440
79 changed files with 608 additions and 255 deletions

View File

@ -290,6 +290,7 @@ CREATE TABLE ir_module_module (
state character varying(16),
latest_version character varying(64),
shortdesc character varying(256),
complexity character varying(32),
category_id integer REFERENCES ir_module_category ON DELETE SET NULL,
certificate character varying(64),
description text,

View File

@ -1002,7 +1002,7 @@
</record>
<record id="main_partner" model="res.partner">
<field name="name">Company Name</field>
<field name="name">Your Company</field>
<!-- Address and Company ID will be set later -->
<field name="address" eval="[]"/>
<field name="company_id" eval="None"/>
@ -1010,14 +1010,7 @@
</record>
<record id="main_address" model="res.partner.address">
<field name="partner_id" ref="main_partner"/>
<field name="name">Company contact name</field>
<field name="street">Company street, number</field>
<field name="zip">Company zip</field>
<field name="city">Company city</field>
<field name="phone">+1-212-555-12345</field>
<field name="type">default</field>
<field model="res.country" name="country_id" ref="us"/>
<!-- Company ID will be set later -->
<field name="company_id" eval="None"/>
</record>
@ -1038,7 +1031,7 @@
<!-- Basic Company -->
<record id="main_company" model="res.company">
<field name="name">Company Name</field>
<field name="name">Your Company</field>
<field name="partner_id" ref="main_partner"/>
<field name="rml_header1">Company business slogan</field>
<field name="rml_footer1">Web: www.companyname.com - Tel: +1-212-555-12345</field>

View File

@ -209,7 +209,7 @@
<group colspan="4" col="6">
<group colspan="4" col="4">
<field name="name"/>
<field name="partner_id" readonly="1" required="0"/>
<field name="partner_id" readonly="1" required="0" groups="base.group_extended"/>
<field name="parent_id" groups="base.group_multi_company"/>
</group>
<group colspan="2" col="2">
@ -225,18 +225,17 @@
<field name="city"/>
<field name="country_id"/>
<field name="state_id"/>
<field name="phone"/>
<field name="email"/>
<field name="fax"/>
<field name="website"/>
<field name="vat"/>
<field name="company_registry"/>
<field name="phone" on_change="on_change_header(phone, email, fax, website, vat, company_registry)"/>
<field name="email" on_change="on_change_header(phone, email, fax, website, vat, company_registry)"/>
<field name="fax" on_change="on_change_header(phone, email, fax, website, vat, company_registry)"/>
<field name="website" on_change="on_change_header(phone, email, fax, website, vat, company_registry)"/>
<field name="vat" on_change="on_change_header(phone, email, fax, website, vat, company_registry)"/>
<field name="company_registry" on_change="on_change_header(phone, email, fax, website, vat, company_registry)"/>
<separator string="Header/Footer of Reports" colspan="4"/>
<group colspan="4" col="3">
<field name="rml_header1" colspan="3"/>
<newline/>
<field name="rml_footer1" colspan="2"/>
<button name="generate_header" string="Generate" type="object" icon="gtk-go-forward"/>
<field name="rml_footer1" colspan="3" groups="base.group_extended"/>
<newline/>
<field name="rml_footer2" colspan="2"/>
<button name="%(bank_account_update)d" string="Set Bank Accounts" type="action" icon="gtk-go-forward"/>
@ -245,10 +244,10 @@
<button name="%(preview_report)d" string="Preview Header" type="action" icon="gtk-print"/>
</group>
</page>
<page string="External Template" groups="base.group_extended">
<page string="Header/Footer" groups="base.group_extended">
<field colspan="4" name="rml_header" nolabel="1"/>
</page>
<page string="Internal Template" groups="base.group_extended">
<page string="Internal Header/Footer" groups="base.group_extended">
<separator string="Portrait" colspan="2"/>
<separator string="Landscape" colspan="2"/>
<field colspan="2" name="rml_header2" nolabel="1"/>

View File

@ -5431,7 +5431,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5431,7 +5431,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5430,7 +5430,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5217,7 +5217,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5572,7 +5572,7 @@ msgstr "Преводи"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Брой на остъпката"
#. module: base

View File

@ -5439,7 +5439,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5709,7 +5709,7 @@ msgstr "Traduccions"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Omplenat del número"
#. module: base

View File

@ -5529,7 +5529,7 @@ msgstr "Překlady"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Zarovnání čísla"
#. module: base

View File

@ -5431,7 +5431,7 @@ msgstr "Oversættelser"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5702,7 +5702,7 @@ msgstr "Übersetzungen"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Stellenanzahl"
#. module: base

View File

@ -5614,7 +5614,7 @@ msgstr "Μεταφράσεις"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Συμπλήρωση αριθμών"
#. module: base

View File

@ -5669,8 +5669,8 @@ msgstr "Translations"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgstr "Number padding"
msgid "Number Padding"
msgstr "Number Padding"
#. module: base
#: view:ir.actions.report.xml:0

View File

@ -5723,7 +5723,7 @@ msgstr "Traducciones"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Relleno del número"
#. module: base

View File

@ -4778,7 +4778,7 @@ msgstr "Traducciones"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Relleno del número"
#. module: base

View File

@ -5725,7 +5725,7 @@ msgstr "Traducciones"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Relleno del número"
#. module: base

View File

@ -5712,7 +5712,7 @@ msgstr "Traducciones"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Relleno del número"
#. module: base

View File

@ -5488,7 +5488,7 @@ msgstr "Tõlked"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Arvu täidistus"
#. module: base

View File

@ -5431,7 +5431,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5496,7 +5496,7 @@ msgstr "برگردان‌ها"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "پیمایش شمارگانی"
#. module: base

View File

@ -5431,7 +5431,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5664,7 +5664,7 @@ msgstr "Käännökset"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Täytenumerot"
#. module: base

View File

@ -5717,7 +5717,7 @@ msgstr "Traductions"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Remplissage"
#. module: base

View File

@ -5695,7 +5695,7 @@ msgstr "Traducións"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Número de enchido"
#. module: base

View File

@ -5472,7 +5472,7 @@ msgstr "תרגומים"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5553,7 +5553,7 @@ msgstr "Prijevodi"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Dopunjavanje na duljinu"
#. module: base

View File

@ -5666,8 +5666,8 @@ msgstr "Fordítások"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgstr "Number padding"
msgid "Number Padding"
msgstr "Number Padding"
#. module: base
#: view:ir.actions.report.xml:0

View File

@ -5431,7 +5431,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5435,7 +5435,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5431,7 +5431,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5713,7 +5713,7 @@ msgstr "Traduzioni"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Riempimento Numero"
#. module: base

View File

@ -5431,7 +5431,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5431,7 +5431,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5457,7 +5457,7 @@ msgstr "번역"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5464,7 +5464,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -4618,7 +4618,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5514,7 +5514,7 @@ msgstr "Tulkojumi"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Ciparu vietas"
#. module: base

View File

@ -5431,7 +5431,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5533,7 +5533,7 @@ msgstr "Орчуулгууд"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Тоон дугаарын урт"
#. module: base

View File

@ -5530,7 +5530,7 @@ msgstr "Oversettelser"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Bunnfyll"
#. module: base

View File

@ -5702,7 +5702,7 @@ msgstr "Vertalingen"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Nummer verspringing"
#. module: base

View File

@ -5447,7 +5447,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -4796,7 +4796,7 @@ msgstr "Vertalingen"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Nummer verspringing"
#. module: base

View File

@ -5612,7 +5612,7 @@ msgstr "Tłumaczenia"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Liczba cyfr"
#. module: base

View File

@ -5591,7 +5591,7 @@ msgstr "Traduções"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Dígitos do número"
#. module: base

View File

@ -5687,7 +5687,7 @@ msgstr "Traduções"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Preencher número"
#. module: base

View File

@ -5555,7 +5555,7 @@ msgstr "Traduceri"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5689,7 +5689,7 @@ msgstr "Переводы"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Выравнивание чисел"
#. module: base

View File

@ -5598,7 +5598,7 @@ msgstr "Preklady"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Zarovanie čísla"
#. module: base

View File

@ -5650,7 +5650,7 @@ msgstr "Prevodi"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Zapolnitev številke"
#. module: base

View File

@ -5430,7 +5430,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5575,7 +5575,7 @@ msgstr "Prevodi"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Dopunjavanje brojeva"
#. module: base

View File

@ -5431,7 +5431,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5624,7 +5624,7 @@ msgstr "Översättningar"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Numerisk utfyllnad"
#. module: base

View File

@ -5431,7 +5431,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5430,7 +5430,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5637,7 +5637,7 @@ msgstr "Çeviriler"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Numara dolgusu"
#. module: base

View File

@ -5495,7 +5495,7 @@ msgstr "Переклади"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Вирівнювання номерів"
#. module: base

View File

@ -4636,7 +4636,7 @@ msgstr "Переклади"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "Вирівнювання номерів"
#. module: base

View File

@ -5431,7 +5431,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5468,7 +5468,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -5471,7 +5471,7 @@ msgstr "翻译"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr "数字位数"
#. module: base

View File

@ -5431,7 +5431,7 @@ msgstr ""
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -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: 2011-01-11 11:14+0000\n"
"PO-Revision-Date: 2011-09-28 13:58+0000\n"
"PO-Revision-Date: 2011-09-29 15:26+0000\n"
"Last-Translator: Walter Cheuk <wwycheuk@gmail.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: 2011-09-29 04:36+0000\n"
"X-Generator: Launchpad (build 14049)\n"
"X-Launchpad-Export-Date: 2011-09-30 04:37+0000\n"
"X-Generator: Launchpad (build 14071)\n"
#. module: base
#: view:ir.filters:0
@ -2795,7 +2795,7 @@ msgstr "向用戶提供目標視窗之額外說明文字,如其用法及用途
#. module: base
#: model:res.country,name:base.va
msgid "Holy See (Vatican City State)"
msgstr "教廷(梵蒂岡)"
msgstr "教廷 (梵蒂岡)"
#. module: base
#: field:base.module.import,module_file:0
@ -5447,7 +5447,7 @@ msgstr "翻譯"
#. module: base
#: field:ir.sequence,padding:0
msgid "Number padding"
msgid "Number Padding"
msgstr ""
#. module: base

View File

@ -176,6 +176,7 @@
<field name="padding"/>
<field name="number_increment"/>
<field name="number_next"/>
<field name="implementation"/>
<separator colspan="4" string="Legend (for prefix, suffix)"/>
<group col="8" colspan="4">
<group>
@ -215,6 +216,7 @@
<field name="company_id" groups="base.group_multi_company"/>
<field name="number_next"/>
<field name="number_increment"/>
<field name="implementation"/>
</tree>
</field>
</record>

View File

@ -19,83 +19,223 @@
#
##############################################################################
import logging
import time
from osv import fields,osv
import pooler
class ir_sequence_type(osv.osv):
import openerp
_logger = logging.getLogger('ir_sequence')
class ir_sequence_type(openerp.osv.osv.osv):
_name = 'ir.sequence.type'
_order = 'name'
_columns = {
'name': fields.char('Name',size=64, required=True),
'code': fields.char('Code',size=32, required=True),
'name': openerp.osv.fields.char('Name', size=64, required=True),
'code': openerp.osv.fields.char('Code', size=32, required=True),
}
ir_sequence_type()
_sql_constraints = [
('code_unique', 'unique(code)', '`code` must be unique.'),
]
def _code_get(self, cr, uid, context={}):
cr.execute('select code, name from ir_sequence_type')
return cr.fetchall()
class ir_sequence(osv.osv):
class ir_sequence(openerp.osv.osv.osv):
""" Sequence model.
The sequence model allows to define and use so-called sequence objects.
Such objects are used to generate unique identifiers in a transaction-safe
way.
"""
_name = 'ir.sequence'
_order = 'name'
_columns = {
'name': fields.char('Name',size=64, required=True),
'code': fields.selection(_code_get, 'Code',size=64, required=True),
'active': fields.boolean('Active'),
'prefix': fields.char('Prefix',size=64, help="Prefix value of the record for the sequence"),
'suffix': fields.char('Suffix',size=64, help="Suffix value of the record for the sequence"),
'number_next': fields.integer('Next Number', required=True, help="Next number of this sequence"),
'number_increment': fields.integer('Increment Number', required=True, help="The next number of the sequence will be incremented by this number"),
'padding' : fields.integer('Number padding', required=True, help="OpenERP will automatically adds some '0' on the left of the 'Next Number' to get the required padding size."),
'company_id': fields.many2one('res.company', 'Company'),
'name': openerp.osv.fields.char('Name', size=64, required=True),
'code': openerp.osv.fields.selection(_code_get, 'Code', size=64),
'implementation': openerp.osv.fields.selection( # TODO update the view
[('standard', 'Standard'), ('no_gap', 'No gap')],
'Implementation', required=True,
help="Two sequence object implementations are offered: Standard "
"and 'No gap'. The later is slower than the former but forbids any"
" gap in the sequence (while they are possible in the former)."),
'active': openerp.osv.fields.boolean('Active'),
'prefix': openerp.osv.fields.char('Prefix', size=64, help="Prefix value of the record for the sequence"),
'suffix': openerp.osv.fields.char('Suffix', size=64, help="Suffix value of the record for the sequence"),
'number_next': openerp.osv.fields.integer('Next Number', required=True, help="Next number of this sequence"),
'number_increment': openerp.osv.fields.integer('Increment Number', required=True, help="The next number of the sequence will be incremented by this number"),
'padding' : openerp.osv.fields.integer('Number Padding', required=True, help="OpenERP will automatically adds some '0' on the left of the 'Next Number' to get the required padding size."),
'company_id': openerp.osv.fields.many2one('res.company', 'Company'),
}
_defaults = {
'active': lambda *a: True,
'implementation': 'standard',
'active': True,
'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'ir.sequence', context=c),
'number_increment': lambda *a: 1,
'number_next': lambda *a: 1,
'padding' : lambda *a : 0,
'number_increment': 1,
'number_next': 1,
'padding' : 0,
}
def _process(self, s):
return (s or '') % {
'year':time.strftime('%Y'),
'month': time.strftime('%m'),
'day':time.strftime('%d'),
'y': time.strftime('%y'),
'doy': time.strftime('%j'),
'woy': time.strftime('%W'),
'weekday': time.strftime('%w'),
'h24': time.strftime('%H'),
'h12': time.strftime('%I'),
'min': time.strftime('%M'),
'sec': time.strftime('%S'),
def init(self, cr):
return # Don't do the following index yet.
# CONSTRAINT/UNIQUE INDEX on (code, company_id)
# /!\ The unique constraint 'unique_name_company_id' is not sufficient, because SQL92
# only support field names in constraint definitions, and we need a function here:
# we need to special-case company_id to treat all NULL company_id as equal, otherwise
# we would allow duplicate (code, NULL) ir_sequences.
cr.execute("""
SELECT indexname FROM pg_indexes WHERE indexname =
'ir_sequence_unique_code_company_id_idx'""")
if not cr.fetchone():
cr.execute("""
CREATE UNIQUE INDEX ir_sequence_unique_code_company_id_idx
ON ir_sequence (code, (COALESCE(company_id,-1)))""")
def _create_sequence(self, cr, id, number_increment, number_next):
""" Create a PostreSQL sequence.
There is no access rights check.
"""
assert isinstance(id, (int, long))
sql = "CREATE SEQUENCE ir_sequence_%03d INCREMENT BY %%s START WITH %%s" % id
cr.execute(sql, (number_increment, number_next))
def _drop_sequence(self, cr, ids):
""" Drop the PostreSQL sequence if it exists.
There is no access rights check.
"""
ids = ids if isinstance(ids, (list, tuple)) else [ids]
assert all(isinstance(i, (int, long)) for i in ids), \
"Only ids in (int, long) allowed."
names = ','.join('ir_sequence_%03d' % i for i in ids)
# RESTRICT is the default; it prevents dropping the sequence if an
# object depends on it.
cr.execute("DROP SEQUENCE IF EXISTS %s RESTRICT " % names)
def _alter_sequence(self, cr, id, number_increment, number_next):
""" Alter a PostreSQL sequence.
There is no access rights check.
"""
assert isinstance(id, (int, long))
cr.execute("""
ALTER SEQUENCE ir_sequence_%03d INCREMENT BY %%s RESTART WITH %%s
""" % id, (number_increment, number_next))
def create(self, cr, uid, values, context=None):
""" Create a sequence, in implementation == standard a fast gaps-allowed PostgreSQL sequence is used.
"""
values = self._add_missing_default_values(cr, uid, values, context)
values['id'] = super(ir_sequence, self).create(cr, uid, values, context)
if values['implementation'] == 'standard':
f = self._create_sequence(cr, values['id'], values['number_increment'], values['number_next'])
return values['id']
def unlink(self, cr, uid, ids, context=None):
super(ir_sequence, self).unlink(cr, uid, ids, context)
self._drop_sequence(cr, ids)
return True
def write(self, cr, uid, ids, values, context=None):
if not isinstance(ids, (list, tuple)):
ids = [ids]
new_implementation = values.get('implementation')
rows = self.read(cr, uid, ids, ['implementation', 'number_increment', 'number_next'], context)
super(ir_sequence, self).write(cr, uid, ids, values, context)
for row in rows:
# 4 cases: we test the previous impl. against the new one.
if row['implementation'] == 'standard':
i = values.get('number_increment', row['number_increment'])
n = values.get('number_next', row['number_next'])
if new_implementation in ('standard', None):
self._alter_sequence(cr, row['id'], i, n)
else:
self._drop_sequence(cr, row['id'])
else:
if new_implementation in ('no_gap', None):
pass
else:
self._create_sequence(cr, row['id'], i, n)
return True
def _interpolate(self, s, d):
if s:
return s % d
return ''
def _interpolation_dict(self):
t = time.localtime() # Actually, the server is always in UTC.
return {
'year': time.strftime('%Y', t),
'month': time.strftime('%m', t),
'day': time.strftime('%d', t),
'y': time.strftime('%y', t),
'doy': time.strftime('%j', t),
'woy': time.strftime('%W', t),
'weekday': time.strftime('%w', t),
'h24': time.strftime('%H', t),
'h12': time.strftime('%I', t),
'min': time.strftime('%M', t),
'sec': time.strftime('%S', t),
}
def get_id(self, cr, uid, sequence_id, test='id', context=None):
assert test in ('code','id')
company_ids = self.pool.get('res.company').search(cr, uid, [], context=context)
cr.execute('''SELECT id, number_next, prefix, suffix, padding
FROM ir_sequence
WHERE %s=%%s
AND active=true
AND (company_id in %%s or company_id is NULL)
ORDER BY company_id, id
FOR UPDATE NOWAIT''' % test,
(sequence_id, tuple(company_ids)))
res = cr.dictfetchone()
if res:
cr.execute('UPDATE ir_sequence SET number_next=number_next+number_increment WHERE id=%s AND active=true', (res['id'],))
if res['number_next']:
return self._process(res['prefix']) + '%%0%sd' % res['padding'] % res['number_next'] + self._process(res['suffix'])
else:
return self._process(res['prefix']) + self._process(res['suffix'])
return False
def _next(self, cr, uid, seq_ids, context=None):
if not seq_ids:
return False
seq = self.read(cr, uid, seq_ids[:1], ['implementation','number_next','prefix','suffix','padding'])[0]
if seq['implementation'] == 'standard':
cr.execute("SELECT nextval('ir_sequence_%03d')" % seq['id'])
seq['number_next'] = cr.fetchone()
else:
cr.execute("SELECT number_next FROM ir_sequence WHERE id=%s FOR UPDATE NOWAIT", (seq['id'],))
cr.execute("UPDATE ir_sequence SET number_next=number_next+number_increment WHERE id=%s ", (seq['id'],))
d = self._interpolation_dict()
interpolated_prefix = self._interpolate(seq['prefix'], d)
interpolated_suffix = self._interpolate(seq['suffix'], d)
return interpolated_prefix + '%%0%sd' % seq['padding'] % seq['number_next'] + interpolated_suffix
def get(self, cr, uid, code):
return self.get_id(cr, uid, code, test='code')
ir_sequence()
def next_by_id(self, cr, uid, sequence_id, context=None):
""" Draw an interpolated string using the specified sequence."""
self.check_read(cr, uid)
company_ids = self.pool.get('res.company').search(cr, uid, [], context=context) + [False]
ids = self.search(cr, uid, ['&',('id','=', sequence_id),('company_id','in',company_ids)])
return self._next(cr, uid, ids, context)
def next_by_code(self, cr, uid, sequence_code, context=None):
""" Draw an interpolated string using the specified sequence."""
self.check_read(cr, uid)
company_ids = self.pool.get('res.company').search(cr, uid, [], context=context) + [False]
ids = self.search(cr, uid, ['&',('code','=', sequence_code),('company_id','in',company_ids)])
return self._next(cr, uid, ids, context)
def get_id(self, cr, uid, sequence_code_or_id, code_or_id='id', context=None):
""" Draw an interpolated string using the specified sequence.
The sequence to use is specified by the ``sequence_code_or_id``
argument, which can be a code or an id (as controlled by the
``code_or_id`` argument. This method is deprecated.
"""
_logger.warning("ir_sequence.get() and ir_sequence.get_id() are deprecated. "
"Please use ir_sequence.next_by_code() or ir_sequence.next_by_id().")
if code_or_id == 'id':
return self.next_by_id(cr, uid, sequence_code_or_id, context)
else:
return self.next_by_code(cr, uid, sequence_code_or_id, context)
def get(self, cr, uid, code, context=None):
""" Draw an interpolated string using the specified sequence.
The sequence to use is specified by its code. This method is
deprecated.
"""
return self.get_id(cr, uid, code, 'code', context)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -88,6 +88,18 @@ class res_company(osv.osv):
result[company.id][field] = address[field] or False
return result
def _get_bank_data(self, cr, uid, ids, field_names, arg, context=None):
""" Read the 'address' functional fields. """
result = {}
for company in self.browse(cr, uid, ids, context=context):
r = []
for bank in company.bank_ids:
if bank.footer:
r.append(bank.name_get(context=context)[0][1])
result[company.id] = ' | '.join(r)
return result
def _set_address_data(self, cr, uid, company_id, name, value, arg, context=None):
""" Write the 'address' functional fields. """
company = self.browse(cr, uid, company_id, context=context)
@ -102,19 +114,9 @@ class res_company(osv.osv):
address_obj.create(cr, uid, {name: value or False, 'partner_id': company.partner_id.id}, context=context)
return True
def _get_bank_data(self, cr, uid, ids, field_names, arg, context=None):
""" Read the 'address' functional fields. """
result = {}
for company in self.browse(cr, uid, ids, context=context):
r = []
for bank in company.bank_ids:
if bank.footer:
r.append(bank.name_get(context=context)[0][1])
result[company.id] = ' | '.join(r)
return result
_columns = {
'name': fields.char('Company Name', size=64, required=True),
'name': fields.related('partner_id', 'name', string='Company Name', size=64, required=True, store=True, type='char'),
'parent_id': fields.many2one('res.company', 'Parent Company', select=True),
'child_ids': fields.one2many('res.company', 'parent_id', 'Child Companies'),
'partner_id': fields.many2one('res.partner', 'Partner', required=True),
@ -146,6 +148,15 @@ class res_company(osv.osv):
_sql_constraints = [
('name_uniq', 'unique (name)', 'The company name must be unique !')
]
def on_change_header(self, cr, uid, ids, phone, email, fax, website, vat, reg=False, context={}):
val = []
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 reg: val.append(_('Reg: ')+reg)
return {'value': {'rml_footer1':' | '.join(val)}}
def _search(self, cr, uid, args, offset=0, limit=None, order=None,
context=None, count=False, access_rights_uid=None):
@ -228,16 +239,6 @@ class res_company(osv.osv):
self.cache_restart(cr)
return super(res_company, self).write(cr, *args, **argv)
def generate_header(self, cr, uid, ids, context=None):
for c in self.browse(cr, uid, ids, context=context):
val = []
if c.phone: val.append(_('Phone: ')+c.phone)
if c.fax: val.append(_('Fax: ')+c.fax)
if c.website: val.append(_('Website: ')+c.website)
if c.vat: val.append(_('VAT: ')+c.vat)
if c.company_registry: val.append(_('Reg: ')+c.company_registry)
self.write(cr,uid, [c.id], {'rml_footer1':' | '.join(val)}, context)
def _get_euro(self, cr, uid, context={}):
try:
return self.pool.get('res.currency').search(cr, uid, [])[0]

View File

@ -75,13 +75,14 @@ def initialize(cr):
cr.execute('INSERT INTO ir_module_module \
(author, website, name, shortdesc, description, \
category_id, state, certificate, web, license) \
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING id', (
category_id, state, certificate, web, license, complexity) \
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING id', (
info['author'],
info['website'], i, info['name'],
info['description'], category_id, state, info['certificate'],
info['web'],
info['license']))
info['license'],
info['complexity']))
id = cr.fetchone()[0]
cr.execute('INSERT INTO ir_model_data \
(name,model,module, res_id, noupdate) VALUES (%s,%s,%s,%s,%s)', (

View File

@ -249,6 +249,7 @@ def load_information_from_description_file(module):
info.setdefault('website', '')
info.setdefault('name', False)
info.setdefault('description', '')
info.setdefault('complexity', False)
info['certificate'] = info.get('certificate') or None
info['web'] = info.get('web') or False
info['license'] = info.get('license') or 'AGPL-3'

View File

@ -131,13 +131,11 @@ class RegistryManager(object):
def get(cls, db_name, force_demo=False, status=None, update_module=False,
pooljobs=True):
""" Return a registry for a given database name."""
with cls.registries_lock:
if db_name in cls.registries:
registry = cls.registries[db_name]
else:
registry = cls.new(db_name, force_demo, status,
update_module, pooljobs)
return registry
try:
return cls.registries[db_name]
except KeyError:
return cls.new(db_name, force_demo, status,
update_module, pooljobs)
@classmethod
def new(cls, db_name, force_demo=False, status=None,
@ -172,10 +170,10 @@ class RegistryManager(object):
finally:
cr.close()
if pooljobs:
registry.schedule_cron_jobs()
if pooljobs:
registry.schedule_cron_jobs()
return registry
return registry
@classmethod
def delete(cls, db_name):
@ -218,4 +216,4 @@ class RegistryManager(object):
cls.registries[db_name].clear_caches()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1285,7 +1285,7 @@ class property(function):
self.field_id = {}
def field_to_dict(self, cr, user, context, field):
def field_to_dict(model, cr, user, field, context=None):
""" Return a dictionary representation of a field.
The string, help, and selection attributes (if any) are untranslated. This
@ -1308,8 +1308,9 @@ def field_to_dict(self, cr, user, context, field):
res['fnct_inv_arg'] = field._fnct_inv_arg or False
res['func_obj'] = field._obj or False
if isinstance(field, many2many):
res['related_columns'] = list((field._id1, field._id2))
res['third_table'] = field._rel
(table, col1, col2) = field._sql_names(model)
res['related_columns'] = [col1, col2]
res['third_table'] = table
for arg in ('string', 'readonly', 'states', 'size', 'required', 'group_operator',
'change_default', 'translate', 'help', 'select', 'selectable'):
if getattr(field, arg):
@ -1328,7 +1329,7 @@ def field_to_dict(self, cr, user, context, field):
res['selection'] = field.selection
else:
# call the 'dynamic selection' function
res['selection'] = field.selection(self, cr, user, context)
res['selection'] = field.selection(model, cr, user, context)
if res['type'] in ('one2many', 'many2many', 'many2one', 'one2one'):
res['relation'] = field._obj
res['domain'] = field._domain

View File

@ -3136,7 +3136,7 @@ class BaseModel(object):
if allfields and f not in allfields:
continue
res[f] = fields.field_to_dict(self, cr, user, context, field)
res[f] = fields.field_to_dict(self, cr, user, field, context=context)
if not write_access:
res[f]['readonly'] = True

View File

@ -43,7 +43,7 @@ class except_osv(Exception):
service = None
class object_proxy():
class object_proxy(object):
def __init__(self):
self.logger = logging.getLogger('web-services')
global service

View File

@ -227,17 +227,18 @@ def wsgi_jsonrpc(environ, start_response):
pass
def wsgi_webdav(environ, start_response):
if environ['REQUEST_METHOD'] == 'OPTIONS' and environ['PATH_INFO'] == '*':
pi = environ['PATH_INFO']
if environ['REQUEST_METHOD'] == 'OPTIONS' and pi in ['*','/']:
return return_options(environ, start_response)
http_dir = websrv_lib.find_http_service(environ['PATH_INFO'])
if http_dir:
path = environ['PATH_INFO'][len(http_dir.path):]
if path.startswith('/'):
environ['PATH_INFO'] = path
else:
environ['PATH_INFO'] = '/' + path
return http_to_wsgi(http_dir)(environ, start_response)
elif pi.startswith('/webdav'):
http_dir = websrv_lib.find_http_service(pi)
if http_dir:
path = pi[len(http_dir.path):]
if path.startswith('/'):
environ['PATH_INFO'] = path
else:
environ['PATH_INFO'] = '/' + path
return http_to_wsgi(http_dir)(environ, start_response)
def return_options(environ, start_response):
# Microsoft specific header, see

62
tests/common.py Normal file
View File

@ -0,0 +1,62 @@
# -*- coding: utf-8 -*-
import os
import time
import unittest2
import xmlrpclib
import openerp
ADDONS_PATH = os.environ['OPENERP_ADDONS_PATH']
PORT = int(os.environ['OPENERP_PORT'])
DB = os.environ['OPENERP_DATABASE']
HOST = '127.0.0.1'
ADMIN_USER = 'admin'
ADMIN_USER_ID = 1
ADMIN_PASSWORD = 'admin'
common_proxy_60 = None
db_proxy_60 = None
object_proxy_60 = None
common_proxy_61 = None
db_proxy_61 = None
model_proxy_61 = None
def setUpModule():
"""
Start the OpenERP server similary to the openerp-server script and
setup some xmlrpclib proxies.
"""
openerp.tools.config['addons_path'] = ADDONS_PATH
openerp.tools.config['xmlrpc_port'] = PORT
openerp.service.start_services()
global common_proxy_60
global db_proxy_60
global object_proxy_60
# Use the old (pre 6.1) API.
url = 'http://%s:%d/xmlrpc/' % (HOST, PORT)
common_proxy_60 = xmlrpclib.ServerProxy(url + 'common')
db_proxy_60 = xmlrpclib.ServerProxy(url + 'db')
object_proxy_60 = xmlrpclib.ServerProxy(url + 'object')
global common_proxy_61
global db_proxy_61
global model_proxy_61
# Use the new (6.1) API.
url = 'http://%s:%d/openerp/6.1/xmlrpc/' % (HOST, PORT)
common_proxy_61 = xmlrpclib.ServerProxy(url + 'common')
db_proxy_61 = xmlrpclib.ServerProxy(url + 'db')
model_proxy_61 = xmlrpclib.ServerProxy(url + 'model/' + DB)
# Ugly way to ensure the server is listening.
time.sleep(2)
def tearDownModule():
""" Shutdown the OpenERP server similarly to a single ctrl-c. """
openerp.service.stop_services()

198
tests/test_ir_sequence.py Normal file
View File

@ -0,0 +1,198 @@
# -*- coding: utf-8 -*-
# Run with one of these commands:
# > OPENERP_ADDONS_PATH='../../addons/trunk' OPENERP_PORT=8069 \
# OPENERP_DATABASE=yy PYTHONPATH=. python tests/test_ir_sequence.py
# > OPENERP_ADDONS_PATH='../../addons/trunk' OPENERP_PORT=8069 \
# OPENERP_DATABASE=yy nosetests tests/test_ir_sequence.py
# > OPENERP_ADDONS_PATH='../../../addons/trunk' OPENERP_PORT=8069 \
# OPENERP_DATABASE=yy PYTHONPATH=../:. unit2 test_ir_sequence
# This assume an existing database.
import os
import psycopg2
import time
import unittest2
import xmlrpclib
import openerp
import common
DB = common.DB
ADMIN_USER_ID = common.ADMIN_USER_ID
setUpModule = common.setUpModule
tearDownModule = common.tearDownModule
def registry(model):
return openerp.modules.registry.RegistryManager.get(DB)[model]
def cursor():
return openerp.modules.registry.RegistryManager.get(DB).db.cursor()
class test_ir_sequence_standard(unittest2.TestCase):
""" A few tests for a 'Standard' (i.e. PostgreSQL) sequence. """
def test_ir_sequence_create(self):
""" Try to create a sequence object. """
cr = cursor()
d = dict(code='test_sequence_type', name='Test sequence type')
c = registry('ir.sequence.type').create(cr, ADMIN_USER_ID, d, {})
assert c
d = dict(code='test_sequence_type', name='Test sequence')
c = registry('ir.sequence').create(cr, ADMIN_USER_ID, d, {})
assert c
cr.commit()
cr.close()
def test_ir_sequence_search(self):
""" Try a search. """
cr = cursor()
ids = registry('ir.sequence').search(cr, ADMIN_USER_ID, [], {})
assert ids
cr.commit()
cr.close()
def test_ir_sequence_draw(self):
""" Try to draw a number. """
cr = cursor()
n = registry('ir.sequence').get(cr, ADMIN_USER_ID, 'test_sequence_type', {})
assert n
cr.commit()
cr.close()
def test_ir_sequence_draw_twice(self):
""" Try to draw a number from two transactions. """
cr0 = cursor()
cr1 = cursor()
n0 = registry('ir.sequence').get(cr0, ADMIN_USER_ID, 'test_sequence_type', {})
assert n0
n1 = registry('ir.sequence').get(cr1, ADMIN_USER_ID, 'test_sequence_type', {})
assert n1
cr0.commit()
cr1.commit()
cr0.close()
cr1.close()
class test_ir_sequence_no_gap(unittest2.TestCase):
""" Copy of the previous tests for a 'No gap' sequence. """
def test_ir_sequence_create_no_gap(self):
""" Try to create a sequence object. """
cr = cursor()
d = dict(code='test_sequence_type_2', name='Test sequence type')
c = registry('ir.sequence.type').create(cr, ADMIN_USER_ID, d, {})
assert c
d = dict(code='test_sequence_type_2', name='Test sequence',
implementation='no_gap')
c = registry('ir.sequence').create(cr, ADMIN_USER_ID, d, {})
assert c
cr.commit()
cr.close()
def test_ir_sequence_draw_no_gap(self):
""" Try to draw a number. """
cr = cursor()
n = registry('ir.sequence').get(cr, ADMIN_USER_ID, 'test_sequence_type_2', {})
assert n
cr.commit()
cr.close()
def test_ir_sequence_draw_twice_no_gap(self):
""" Try to draw a number from two transactions.
This is expected to not work.
"""
cr0 = cursor()
cr1 = cursor()
msg_re = '^could not obtain lock on row in relation "ir_sequence"$'
with self.assertRaisesRegexp(psycopg2.OperationalError, msg_re):
n0 = registry('ir.sequence').get(cr0, ADMIN_USER_ID, 'test_sequence_type_2', {})
assert n0
n1 = registry('ir.sequence').get(cr1, ADMIN_USER_ID, 'test_sequence_type_2', {})
cr0.close()
cr1.close()
class test_ir_sequence_change_implementation(unittest2.TestCase):
""" Create sequence objects and change their ``implementation`` field. """
def test_ir_sequence_1_create(self):
""" Try to create a sequence object. """
cr = cursor()
d = dict(code='test_sequence_type_3', name='Test sequence type')
c = registry('ir.sequence.type').create(cr, ADMIN_USER_ID, d, {})
assert c
d = dict(code='test_sequence_type_3', name='Test sequence')
c = registry('ir.sequence').create(cr, ADMIN_USER_ID, d, {})
assert c
d = dict(code='test_sequence_type_4', name='Test sequence type')
c = registry('ir.sequence.type').create(cr, ADMIN_USER_ID, d, {})
assert c
d = dict(code='test_sequence_type_4', name='Test sequence',
implementation='no_gap')
c = registry('ir.sequence').create(cr, ADMIN_USER_ID, d, {})
assert c
cr.commit()
cr.close()
def test_ir_sequence_2_write(self):
cr = cursor()
ids = registry('ir.sequence').search(cr, ADMIN_USER_ID,
[('code', 'in', ['test_sequence_type_3', 'test_sequence_type_4'])], {})
registry('ir.sequence').write(cr, ADMIN_USER_ID, ids,
{'implementation': 'standard'}, {})
registry('ir.sequence').write(cr, ADMIN_USER_ID, ids,
{'implementation': 'no_gap'}, {})
cr.commit()
cr.close()
def test_ir_sequence_3_unlink(self):
cr = cursor()
ids = registry('ir.sequence').search(cr, ADMIN_USER_ID,
[('code', 'in', ['test_sequence_type_3', 'test_sequence_type_4'])], {})
registry('ir.sequence').unlink(cr, ADMIN_USER_ID, ids, {})
cr.commit()
cr.close()
class test_ir_sequence_generate(unittest2.TestCase):
""" Create sequence objects and generate some values. """
def test_ir_sequence_create(self):
""" Try to create a sequence object. """
cr = cursor()
d = dict(code='test_sequence_type_5', name='Test sequence type')
c = registry('ir.sequence.type').create(cr, ADMIN_USER_ID, d, {})
assert c
d = dict(code='test_sequence_type_5', name='Test sequence')
c = registry('ir.sequence').create(cr, ADMIN_USER_ID, d, {})
assert c
cr.commit()
cr.close()
cr = cursor()
f = lambda *a: registry('ir.sequence').get(cr, ADMIN_USER_ID, 'test_sequence_type_5', {})
assert all(str(x) == f() for x in xrange(1,1000))
cr.commit()
cr.close()
def test_ir_sequence_create_no_gap(self):
""" Try to create a sequence object. """
cr = cursor()
d = dict(code='test_sequence_type_6', name='Test sequence type',
implementation='no_gap')
c = registry('ir.sequence.type').create(cr, ADMIN_USER_ID, d, {})
assert c
d = dict(code='test_sequence_type_6', name='Test sequence')
c = registry('ir.sequence').create(cr, ADMIN_USER_ID, d, {})
assert c
cr.commit()
cr.close()
cr = cursor()
f = lambda *a: registry('ir.sequence').get(cr, ADMIN_USER_ID, 'test_sequence_type_6', {})
assert all(str(x) == f() for x in xrange(1,1000))
cr.commit()
cr.close()
if __name__ == '__main__':
unittest2.main()

View File

@ -12,60 +12,15 @@ import unittest2
import xmlrpclib
import openerp
import common
ADDONS_PATH = os.environ['OPENERP_ADDONS_PATH']
PORT = int(os.environ['OPENERP_PORT'])
DB = os.environ['OPENERP_DATABASE']
DB = common.DB
ADMIN_USER = common.ADMIN_USER
ADMIN_USER_ID = common.ADMIN_USER_ID
ADMIN_PASSWORD = common.ADMIN_PASSWORD
HOST = '127.0.0.1'
ADMIN_USER = 'admin'
ADMIN_USER_ID = 1
ADMIN_PASSWORD = 'admin'
common_proxy_60 = None
db_proxy_60 = None
object_proxy_60 = None
common_proxy_61 = None
db_proxy_61 = None
model_proxy_61 = None
def setUpModule():
"""
Start the OpenERP server similary to the openerp-server script and
setup some xmlrpclib proxies.
"""
openerp.tools.config['addons_path'] = ADDONS_PATH
openerp.tools.config['xmlrpc_port'] = PORT
openerp.service.start_services()
global common_proxy_60
global db_proxy_60
global object_proxy_60
global common_proxy_61
global db_proxy_61
global model_proxy_61
# Use the old (pre 6.1) API.
url = 'http://%s:%d/xmlrpc/' % (HOST, PORT)
common_proxy_60 = xmlrpclib.ServerProxy(url + 'common')
db_proxy_60 = xmlrpclib.ServerProxy(url + 'db')
object_proxy_60 = xmlrpclib.ServerProxy(url + 'object')
# Use the new (6.1) API.
url = 'http://%s:%d/openerp/6.1/xmlrpc/' % (HOST, PORT)
common_proxy_61 = xmlrpclib.ServerProxy(url + 'common')
db_proxy_61 = xmlrpclib.ServerProxy(url + 'db')
model_proxy_61 = xmlrpclib.ServerProxy(url + 'model/' + DB)
# Mmm need to make sure the server is listening for XML-RPC requests.
time.sleep(10)
def tearDownModule():
""" Shutdown the OpenERP server similarly to a single ctrl-c. """
openerp.service.stop_services()
setUpModule = common.setUpModule
tearDownModule = common.tearDownModule
class test_xmlrpc(unittest2.TestCase):
@ -74,34 +29,34 @@ class test_xmlrpc(unittest2.TestCase):
Simulate a OpenERP client requesting the creation of a database and
polling the server until the creation is complete.
"""
progress_id = db_proxy_60.create(ADMIN_PASSWORD, DB, True, False,
ADMIN_PASSWORD)
progress_id = common.db_proxy_60.create(ADMIN_PASSWORD, DB, True,
False, ADMIN_PASSWORD)
while True:
time.sleep(1)
progress, users = db_proxy_60.get_progress(ADMIN_PASSWORD,
progress, users = common.db_proxy_60.get_progress(ADMIN_PASSWORD,
progress_id)
if progress == 1.0:
break
def test_xmlrpc_login(self):
""" Try to login on the common service. """
uid = common_proxy_60.login(DB, ADMIN_USER, ADMIN_PASSWORD)
uid = common.common_proxy_60.login(DB, ADMIN_USER, ADMIN_PASSWORD)
assert uid == ADMIN_USER_ID
def test_xmlrpc_ir_model_search(self):
""" Try a search on the object service. """
ids = object_proxy_60.execute(DB, ADMIN_USER_ID, ADMIN_PASSWORD,
ids = common.object_proxy_60.execute(DB, ADMIN_USER_ID, ADMIN_PASSWORD,
'ir.model', 'search', [])
assert ids
ids = object_proxy_60.execute(DB, ADMIN_USER_ID, ADMIN_PASSWORD,
ids = common.object_proxy_60.execute(DB, ADMIN_USER_ID, ADMIN_PASSWORD,
'ir.model', 'search', [], {})
assert ids
def test_xmlrpc_61_ir_model_search(self):
""" Try a search on the object service. """
ids = model_proxy_61.execute(ADMIN_USER_ID, ADMIN_PASSWORD, 'ir.model', 'search', [])
ids = common.model_proxy_61.execute(ADMIN_USER_ID, ADMIN_PASSWORD, 'ir.model', 'search', [])
assert ids
ids = model_proxy_61.execute(ADMIN_USER_ID, ADMIN_PASSWORD, 'ir.model', 'search', [], {})
ids = common.model_proxy_61.execute(ADMIN_USER_ID, ADMIN_PASSWORD, 'ir.model', 'search', [], {})
assert ids
if __name__ == '__main__':