From 9faf27da5ecef92f5e6909ea69d33b21563db4f9 Mon Sep 17 00:00:00 2001 From: Michael Telahun Makonnen Date: Thu, 27 Dec 2012 10:52:00 +0300 Subject: [PATCH 001/315] Enable loading of Amharic (Ethiopia) language. bzr revid: mmakonnen@gmail.com-20121227075200-junjlo2sj4vxk87h --- openerp/tools/misc.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openerp/tools/misc.py b/openerp/tools/misc.py index 47a2ae4faac..1d40006144e 100644 --- a/openerp/tools/misc.py +++ b/openerp/tools/misc.py @@ -433,6 +433,7 @@ def get_iso_codes(lang): ALL_LANGUAGES = { 'ab_RU': u'Abkhazian / аҧсуа', + 'am_ET': u'Amharic / አምሃርኛ', 'ar_SY': u'Arabic / الْعَرَبيّة', 'bg_BG': u'Bulgarian / български език', 'bs_BS': u'Bosnian / bosanski jezik', From 1cb348e1334284665f3d29545be3863e5b8dd54f Mon Sep 17 00:00:00 2001 From: "Hiral Patel (OpenERP)" Date: Thu, 10 Jan 2013 15:44:59 +0530 Subject: [PATCH 002/315] [7.0][project_crm][FIX] sale_order_id does not appear in the correct location on project.task bzr revid: hip@tinyerp.com-20130110101459-c5q6t465i4p8nftk --- addons/project_mrp/project_mrp_view.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/project_mrp/project_mrp_view.xml b/addons/project_mrp/project_mrp_view.xml index 881ed9b6b29..499a0259214 100644 --- a/addons/project_mrp/project_mrp_view.xml +++ b/addons/project_mrp/project_mrp_view.xml @@ -26,9 +26,9 @@ project.task - + - + From bc9b5036620ddf8b7929249a684b289af5668635 Mon Sep 17 00:00:00 2001 From: "Hiral Patel (OpenERP)" Date: Tue, 15 Jan 2013 14:40:39 +0530 Subject: [PATCH 003/315] [trunk] Display Click to set your company logo in edit mode bzr revid: hip@tinyerp.com-20130115091039-h6cjblnuzzyro4ym --- openerp/addons/base/res/res_company_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/addons/base/res/res_company_view.xml b/openerp/addons/base/res/res_company_view.xml index 06775d159ac..c5840976324 100644 --- a/openerp/addons/base/res/res_company_view.xml +++ b/openerp/addons/base/res/res_company_view.xml @@ -33,7 +33,7 @@
-

+

Click to set your company logo.

From 4f0074193f95595ba15fa81a4a01837733c7308c Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Tue, 15 Jan 2013 16:21:31 +0100 Subject: [PATCH 004/315] [FIX] report_webkit - ir_report xml view lp bug: https://launchpad.net/bugs/1099880 fixed bzr revid: yannick.vaucher@camptocamp.com-20130115152131-84q6nto42w6zk24t --- addons/report_webkit/ir_report_view.xml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/report_webkit/ir_report_view.xml b/addons/report_webkit/ir_report_view.xml index e9f9ebd2234..8eca63e57b4 100644 --- a/addons/report_webkit/ir_report_view.xml +++ b/addons/report_webkit/ir_report_view.xml @@ -7,11 +7,15 @@ - - - + + + + + - + + + From a15920f684a0d9c357ed53e6254915bb6e127ff4 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Wed, 16 Jan 2013 17:00:08 +0530 Subject: [PATCH 005/315] [FIX] Chnage Default currency of Estonia to EUR from EEK as it have changed from 2011 bzr revid: tpa@tinyerp.com-20130116113008-8l9mof3qzhyrxhso --- openerp/addons/base/currency_data.xml | 13 ------------- openerp/addons/base/res/res_country_data.xml | 2 +- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/openerp/addons/base/currency_data.xml b/openerp/addons/base/currency_data.xml index 7173b8492ab..c0900f39092 100644 --- a/openerp/addons/base/currency_data.xml +++ b/openerp/addons/base/currency_data.xml @@ -1017,19 +1017,6 @@ 18.89
- - EEK - kr - 0.01 - 4 - - - - - - 14.41 - - ETB Br diff --git a/openerp/addons/base/res/res_country_data.xml b/openerp/addons/base/res/res_country_data.xml index a7cfb961af1..55818cb5c39 100644 --- a/openerp/addons/base/res/res_country_data.xml +++ b/openerp/addons/base/res/res_country_data.xml @@ -330,7 +330,7 @@ Estonia ee - + Egypt From 8d47d83bbf7aab82859f269a670b63bd43689bf5 Mon Sep 17 00:00:00 2001 From: "Bhumi Thakkar (Open ERP)" Date: Thu, 17 Jan 2013 17:28:14 +0530 Subject: [PATCH 006/315] [FIX] config_id problem with pos session.--fixes:lp1098226 bzr revid: bth@tinyerp.com-20130117115814-kf2365ydkq5fwu5i --- addons/point_of_sale/point_of_sale.py | 2 +- addons/point_of_sale/wizard/pos_session_opening.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 970eb1fbed7..22a6b5cd95b 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -290,7 +290,7 @@ class pos_session(osv.osv): _constraints = [ (_check_unicity, "You cannot create two active sessions with the same responsible!", ['user_id', 'state']), - (_check_pos_config, "You cannot create two active sessions related to the same point of sale!", ['config_id']), + (_check_pos_config, "You cannot create two active sessions related to the same point of sale! Use not used point of sale", ['config_id']), ] def create(self, cr, uid, values, context=None): diff --git a/addons/point_of_sale/wizard/pos_session_opening.py b/addons/point_of_sale/wizard/pos_session_opening.py index 1aa4cb702c4..ac64da706aa 100644 --- a/addons/point_of_sale/wizard/pos_session_opening.py +++ b/addons/point_of_sale/wizard/pos_session_opening.py @@ -88,6 +88,7 @@ class pos_session_opening(osv.osv_memory): session_ids = proxy.search(cr, uid, [ ('state', '!=', 'closed'), ('config_id', '=', config_id), + ('user_id', '=', uid), ], context=context) if session_ids: session = proxy.browse(cr, uid, session_ids[0], context=context) From 75ee662647d0209516997bdce7bed23afa1c32af Mon Sep 17 00:00:00 2001 From: Niels Huylebroeck Date: Fri, 25 Jan 2013 17:07:11 +0100 Subject: [PATCH 007/315] [FIX] account_payment: imported payments from invoices on payment order do not reflect the reference type of the invoice lp bug: https://launchpad.net/bugs/1105067 fixed bzr revid: nh@agaplan.eu-20130125160711-cofis6ftzw3zvcza --- addons/account_payment/wizard/account_payment_order.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/account_payment/wizard/account_payment_order.py b/addons/account_payment/wizard/account_payment_order.py index 455475b0ae5..60b1bc9c1d1 100644 --- a/addons/account_payment/wizard/account_payment_order.py +++ b/addons/account_payment/wizard/account_payment_order.py @@ -88,6 +88,7 @@ class payment_order_create(osv.osv_memory): 'partner_id': line.partner_id and line.partner_id.id or False, 'communication': line.ref or '/', 'date': date_to_pay, + 'state': line.invoice and line.invoice.reference_type != 'none' and 'structured' or 'normal', 'currency': (line.invoice and line.invoice.currency_id.id) or line.journal_id.currency.id or line.journal_id.company_id.currency_id.id, }, context=context) return {'type': 'ir.actions.act_window_close'} From 2ace4972e671934526ad9f501e22d570ab3d062f Mon Sep 17 00:00:00 2001 From: Peter Langenberg Date: Tue, 29 Jan 2013 15:34:28 +0100 Subject: [PATCH 008/315] [FIX]l10n_be_coda Agaplan 661 OpenERP Maintenance bzr revid: pl@agaplan.eu-20130129143428-l74j4vzt8z8j6ebr --- addons/l10n_be_coda/wizard/account_coda_import.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/l10n_be_coda/wizard/account_coda_import.py b/addons/l10n_be_coda/wizard/account_coda_import.py index 213040d6204..78d3dbcc545 100644 --- a/addons/l10n_be_coda/wizard/account_coda_import.py +++ b/addons/l10n_be_coda/wizard/account_coda_import.py @@ -246,7 +246,7 @@ class account_coda_import(osv.osv_memory): elif line[0] == '9': statement['balanceMin'] = float(rmspaces(line[22:37])) / 1000 statement['balancePlus'] = float(rmspaces(line[37:52])) / 1000 - if not statement['balance_end_real']: + if not statement.get('balance_end_real'): statement['balance_end_real'] = statement['balance_start'] + statement['balancePlus'] - statement['balanceMin'] for i, statement in enumerate(statements): statement['coda_note'] = '' From 9d10d3e198d74679bf9db072175a3031f1fc16c1 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Tue, 29 Jan 2013 11:52:07 -0500 Subject: [PATCH 009/315] [FIX] Replaced french leftover tax names in l10n_ca's account_tax_en.xml. Replaced TVH by HST and TVQ by QST. lp bug: https://launchpad.net/bugs/1095382 fixed bzr revid: virgil.dupras@savoirfairelinux.com-20130129165207-xnul9189p27nqcm1 --- addons/l10n_ca/__openerp__.py | 2 +- addons/l10n_ca/account_tax_en.xml | 48 +++++++++++++++---------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/addons/l10n_ca/__openerp__.py b/addons/l10n_ca/__openerp__.py index 05279b6ef8e..af6e4c95078 100644 --- a/addons/l10n_ca/__openerp__.py +++ b/addons/l10n_ca/__openerp__.py @@ -20,7 +20,7 @@ ############################################################################## { 'name': 'Canada - Accounting', - 'version': '1.0', + 'version': '1.1', 'author': 'Savoir-faire Linux', 'website': 'http://www.savoirfairelinux.com', 'category': 'Localization/Account Charts', diff --git a/addons/l10n_ca/account_tax_en.xml b/addons/l10n_ca/account_tax_en.xml index 1ff884ac361..d7c9ffd38a2 100644 --- a/addons/l10n_ca/account_tax_en.xml +++ b/addons/l10n_ca/account_tax_en.xml @@ -102,8 +102,8 @@ - GST + TVQ for sales - GSTTVQ_SALE + GST + QST for sales + GSTQST_SALE sale 1 1 @@ -129,8 +129,8 @@ - TVQ for sales - 9.975% - TVQ + QST for sales - 9.975% + QST sale 0.099750 percent @@ -195,8 +195,8 @@ - TVH for sales - 12% - TVH12_SALE + HST for sales - 12% + HST12_SALE sale 0.120000 percent @@ -210,8 +210,8 @@ - TVH for sales - 13% - TVH13_SALE + HST for sales - 13% + HST13_SALE sale 0.130000 percent @@ -225,8 +225,8 @@ - TVH for sales - 13.5% - TVH135_SALE + HST for sales - 13.5% + HST135_SALE sale 0.135000 percent @@ -240,8 +240,8 @@ - TVH for sales - 15% - TVH15_SALE + HST for sales - 15% + HST15_SALE sale 0.150000 percent @@ -371,8 +371,8 @@ - GST + TVQ for purchases - GSTTVQ_PURC + GST + QST for purchases + GSTQST_PURC purchase 1 1 @@ -398,8 +398,8 @@ - TVQ for purchases - 9.975% - TVQ + QST for purchases - 9.975% + QST purchase 0.099750 percent @@ -464,8 +464,8 @@ - TVH for purchases - 12% - TVH12_PURC + HST for purchases - 12% + HST12_PURC purchase 0.120000 percent @@ -479,8 +479,8 @@ - TVH for purchases - 13% - TVH13_PURC + HST for purchases - 13% + HST13_PURC purchase 0.130000 percent @@ -494,8 +494,8 @@ - TVH for purchases - 13.5% - TVH135_PURC + HST for purchases - 13.5% + HST135_PURC purchase 0.135000 percent @@ -509,8 +509,8 @@ - TVH for purchases - 15% - TVH15_PURC + HST for purchases - 15% + HST15_PURC purchase 0.150000 percent From 489c5df81440202236ab37ffb2fade69f85b906e Mon Sep 17 00:00:00 2001 From: Peter Langenberg Date: Tue, 5 Feb 2013 09:37:06 +0100 Subject: [PATCH 010/315] [FIX]l10n_be_invoice_bba error message when duplicating lp bug: https://launchpad.net/bugs/1115472 fixed bzr revid: pl@agaplan.eu-20130205083706-sekknxzcl30ni9bn --- addons/l10n_be_invoice_bba/invoice.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addons/l10n_be_invoice_bba/invoice.py b/addons/l10n_be_invoice_bba/invoice.py index a23dabd7c51..97cc4ed5d7c 100644 --- a/addons/l10n_be_invoice_bba/invoice.py +++ b/addons/l10n_be_invoice_bba/invoice.py @@ -199,6 +199,18 @@ class account_invoice(osv.osv): '\nPlease create manually a unique BBA Structured Communication.')) return super(account_invoice, self).write(cr, uid, ids, vals, context) + def copy(self, cr, uid, ids, default=None, context=None): + default = default or {} + invoice = self.browse(cr, uid, ids, context=context) + reference_type = invoice.reference_type or 'none' + default['reference_type'] = reference_type + if reference_type == 'bba': + partner = invoice.partner_id + default['reference'] = self.generate_bbacomm(cr, uid, ids, + invoice.type, reference_type, + partner.id, '', context=context)['value']['reference'] + return super(account_invoice, self).copy(cr, uid, ids, default, context=context) + _columns = { 'reference': fields.char('Communication', size=64, help="The partner reference of this invoice."), 'reference_type': fields.selection(_get_reference_type, 'Communication Type', From 964bb5a7caa44a71268ed438950ffe2dd4bf26db Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Mon, 11 Feb 2013 11:42:49 +0100 Subject: [PATCH 011/315] [FIX] report_webkit - __openerp__.py descriptor, correct explanation on how to set the wkhtmltopdf path lp bug: https://launchpad.net/bugs/1113418 fixed bzr revid: yannick.vaucher@camptocamp.com-20130211104249-ipobmq3a2q8ycygu --- addons/report_webkit/__openerp__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/report_webkit/__openerp__.py b/addons/report_webkit/__openerp__.py index 5b88cb78eb4..ec71ee37b0c 100644 --- a/addons/report_webkit/__openerp__.py +++ b/addons/report_webkit/__openerp__.py @@ -62,8 +62,9 @@ This module requires the ``wkthtmltopdf`` library to render HTML documents as PDF. Version 0.9.9 or later is necessary, and can be found at http://code.google.com/p/wkhtmltopdf/ for Linux, Mac OS X (i386) and Windows (32bits). -After installing the library on the OpenERP Server machine, you need to set the -path to the ``wkthtmltopdf`` executable file on each Company. +After installing the library on the OpenERP Server machine, you need to set +the path to the ``wkthtmltopdf`` executable file in a system parameter named ``webkit_path`` +in Settings -> Customization -> Low Level Object -> System Parameters If you are experiencing missing header/footer problems on Linux, be sure to install a 'static' version of the library. The default ``wkhtmltopdf`` on From fd485cd9e71202c1180322001c0fee1d921d6a6a Mon Sep 17 00:00:00 2001 From: "Pinakin Nayi (OpenERP)" Date: Thu, 14 Feb 2013 18:08:56 +0530 Subject: [PATCH 012/315] [FIX]account_analytic_plans:open analytic rules and try to groupby analytic account it not getting analytic account in tree view so generate client error bzr revid: pna@tinyerp.com-20130214123856-hr30ewdc9rrwhimq --- addons/account_analytic_plans/account_analytic_plans_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account_analytic_plans/account_analytic_plans_view.xml b/addons/account_analytic_plans/account_analytic_plans_view.xml index 3dcbcda6952..dbd793af5ae 100644 --- a/addons/account_analytic_plans/account_analytic_plans_view.xml +++ b/addons/account_analytic_plans/account_analytic_plans_view.xml @@ -272,7 +272,7 @@ account.analytic.default - + From de240e28183be881078af89893b504fc6478051a Mon Sep 17 00:00:00 2001 From: Peter Langenberg Date: Thu, 14 Feb 2013 13:58:41 +0100 Subject: [PATCH 013/315] [fix]l10n_be_coda/wizard/account_coda_import.py warning No transactions or no period in coda file ! to avoid key error lp bug: https://launchpad.net/bugs/1125165 fixed bzr revid: pl@agaplan.eu-20130214125841-ytdwspwug910v1hv --- addons/l10n_be_coda/wizard/account_coda_import.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/l10n_be_coda/wizard/account_coda_import.py b/addons/l10n_be_coda/wizard/account_coda_import.py index 78d3dbcc545..b952ee5d0f6 100644 --- a/addons/l10n_be_coda/wizard/account_coda_import.py +++ b/addons/l10n_be_coda/wizard/account_coda_import.py @@ -264,6 +264,8 @@ class account_coda_import(osv.osv_memory): raise osv.except_osv(_('Error'), _("Configuration Error in journal %s!\nPlease verify the Default Debit and Credit Account settings.") % statement['journal_id'].name) if balance_start_check != statement['balance_start']: statement['coda_note'] = _("The CODA Statement %s Starting Balance (%.2f) does not correspond with the previous Closing Balance (%.2f) in journal %s!") % (statement['description'] + ' #' + statement['paperSeqNumber'], statement['balance_start'], balance_start_check, statement['journal_id'].name) + if not(statement.get('period_id')): + raise osv.except_osv(_('Error') + ' R3006', _(' No transactions or no period in coda file !')) data = { 'name': statement['paperSeqNumber'], 'date': statement['date'], From 1f5e98aa591855da34b2b982cb459b629b2d50d6 Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Fri, 15 Feb 2013 15:34:37 +0530 Subject: [PATCH 014/315] [FIX]stock: added domain and default search to display proper user on proper field [customer, supplier] bzr revid: mma@tinyerp.com-20130215100437-d8ke7al2ef0ma1jb --- addons/stock/stock_view.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index a559aad9aac..9bf0ae8a55e 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -908,7 +908,7 @@ - + @@ -1034,7 +1034,7 @@ -
From 28ed62fd7e22fe79d856926e6ce91aba5f0dd429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Wed, 27 Mar 2013 16:15:18 +0100 Subject: [PATCH 056/315] [IMP] point_of_sale: adding visual feedback when clicking on buttons bzr revid: fva@openerp.com-20130327151518-t4h67hqn02s80tai --- addons/point_of_sale/static/src/css/pos.css | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/addons/point_of_sale/static/src/css/pos.css b/addons/point_of_sale/static/src/css/pos.css index 16355240f25..e328054aa28 100644 --- a/addons/point_of_sale/static/src/css/pos.css +++ b/addons/point_of_sale/static/src/css/pos.css @@ -307,6 +307,17 @@ border-top: 1px solid #efefef; font-size: 14px; } +.point-of-sale #paypad button, .point-of-sale #numpad button, .point-of-sale .popup button{ + position: relative; + top: 0; + -webkit-transition: top 150ms linear; + -moz-transition: top 150ms linear; + -ms-transition: top 150ms linear; + transition: top 150ms linear; +} +.point-of-sale #paypad button:active, .point-of-sale #numpad button:active, .point-of-sale .popup button:active{ + top:3px; +} .point-of-sale #paypad button:hover, .point-of-sale #numpad button:hover, .point-of-sale #numpad .selected-mode, .point-of-sale .popup button:hover { border: none; color: white; From 74b3538dd17b291c47fcb5697484506c66d6429d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Wed, 27 Mar 2013 16:40:54 +0100 Subject: [PATCH 057/315] [IMP] point_of_sale: add an invoice button (does nothing yet) bzr revid: fva@openerp.com-20130327154054-nhfy6ak73v1gwj09 --- .../static/src/img/icons/png48/invoice.png | Bin 0 -> 2086 bytes addons/point_of_sale/static/src/js/screens.js | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 addons/point_of_sale/static/src/img/icons/png48/invoice.png diff --git a/addons/point_of_sale/static/src/img/icons/png48/invoice.png b/addons/point_of_sale/static/src/img/icons/png48/invoice.png new file mode 100644 index 0000000000000000000000000000000000000000..e65d2ec5a67398a6aa245c89d66355ae3e5a0d46 GIT binary patch literal 2086 zcmV+>2-)|EP)3$g6o3^(HlyMaw}_JX0}^BWW6(b){xLDe#69s3KTTXhkf3a>RIF5r#a2ppT9Cp( zX**@6oo>(~2BX!1(q-Cdk)@Sx)0w_5vrp%E&h6>Dym>5nbq1ri`7+a)dGDR?oOADe zGj{;Mf13ZVKy!1=qbHi{iyE71{S7B=K-8b8(NNb|t)aHTs$#1rEGjj1$B9T?qxFid z!D_SCR;{&KtxFOn(AZ?l86Fv$hB%IJBn)2P6bug!z}Yst-&R*WQC(+FZf00aVl@C$t4^LxSP^NK*Gyu>6-PE8==Fflm};}Z%p2Fkbx#t@I<2G7_i zxRFth3&s==p2LUd4T2m0x1VqESJzhkQr1{@Ut9%h8>++jD1!F;IdB96Cn#`z@RN!V zP-X=bLJCm8qwW!KxrgyJHw1$Lah#*OJ!G+&`z)5S6>$^5z7+y8Xc@SG0%tG?L;;z7 zf`cb!gBQ#Q3=aPVSNbkN043-cXRl+rs=8dMtSoyeE&|oH$A!R@ZzkXi7cM}1dwbky zYiol}M>`A-4UmM8?ETXTW=pxZqT z(BWtk0yM-D>lzXgzx?)d;8>;U=$r-2mSZHKwntBoGwv0z+wE}r^l3PC>JKkgj2M_Q6U`_%RRYyrcW|$e%AhRwrKT4SwxCPkzoP7aT0Kp*p!P(OV zzuSL<=ATZ2#aac2O{HM2s({{$Jz_qXj+OQUz@3H#um@2f3JR^|h%*5dXl-qUGiS~~ zeSJNc&1NV)REh$JplDwK6c!c0#Y??VQ+s^kK3=5Q1m`FfwMk<Am zM`izO=KwT6}YBZfX0Y{FRQ0O3>J8y@Bhl&pv7C2gdC>$jL z4wNg9a5_6X#T*zK8Gyd4mua&@fs)IH1x#h7BtRLaYzjOQ{r?(V-1`Dq1^4V6kbA+1 zUx!xAh|Se$2E0M}j?a3#C~ z-2c=*ETAF;@{4ke3+(@~P$MAFXPV%BK<*6$?-zvJCloz=en!7<&_a?|xYxMAz5@lC z7V7G9+>TXrkF`$>Uu~a8hiF;Mp9A? z3gqPNApz=1UEunlwE@%pix&Dt<0jzyF~_LqqLG!o+qgh>ZWi4OsgsevktH05!$AV7 z6phRuGK>rC$;l)E%D5)$+}FBn%Z!R2z!)F+iNGxW8{m^apvC-%Mq_u@F5?1NwlD|* zu}WYCdTv_B`!s2K3NF*Ydo|Z(22q8WbBQhgFW9P0N#s$9Hy%PmM73k^hxgFn! zDFM`4Y9(l-?MyW;ke-po0=iX4_C8NG+4s8aQ+7G?(=Z*K7PrSV=#dbwb0uUIv;sT6 z{o1$ymW^9TSAm4n-QBGbNKO07m;jDD)6!E(;1(;8S6hW3!Yhxgf}96j4T-M*^%I%K z*WYZ5tY5!=@y!J|aAy9FZ>7Na+*cvGi>01s89gCQ;DmN5rIC`F99gqw%~FhO9>u2@ z;NbZKcOi>X)3yr%1qE)s1AA}27x3KB5gW7&T-}*zZ2KxHvU>IE2QjX@DY-167vSI* zBM*F&w%tn;i~?75w-Gnk(5@BH%CHc_fvN;JXc@S=JV)^_Ib~~j*|KHJF|K=&g;GK* zFpmxILzaKOX@jNp{JAI&_%}zlvkTUJ_Ng6XdJcI6S;C3d3$We&$WyDHUG?_bb)WpY zZF^GW%apCaU^ccu^0pb01e+o0%Ne#3$(vNR5J?+VHWORF5Nsm0e6F&Q*t|jT1%uC{ zAAS5`$I6u}*J4c1Bab3WZziySKkzW}4Dtf<3i2BA2J$BIF7h7pe%z4fe21^|I`S&= zG6(-8vJ6>t{TAZYhudfgSK=YIewhpD;Kpx|^d64^mF=u~XjDUV6 zVv&VxyqKi8I`<@)rOXn(?jnw30Vh}uUJB?WSVS^kf^vyvz7~#w 0); + this.pos_widget.action_bar.set_button_disabled('invoice', remaining > 0); } }, set_numpad_state: function(numpadState) { From 0bdf0ebaf57fd7a4d52132f800366b251d2eab82 Mon Sep 17 00:00:00 2001 From: "Rajesh Prajapati (OpenERP)" Date: Thu, 28 Mar 2013 10:57:01 +0530 Subject: [PATCH 058/315] [IMP] google_docs : changes for view bzr revid: rpr@tinyerp.com-20130328052701-mmcmth3ie6c1kwgc --- addons/google_base_account/google_base_account_view.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/addons/google_base_account/google_base_account_view.xml b/addons/google_base_account/google_base_account_view.xml index 999a299fd92..366c39f6414 100644 --- a/addons/google_base_account/google_base_account_view.xml +++ b/addons/google_base_account/google_base_account_view.xml @@ -22,12 +22,10 @@ - -
From 074661f4c7162193701cf0321d0532d880b6db9e Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Thu, 28 Mar 2013 11:55:10 +0530 Subject: [PATCH 059/315] [IMP]: google_docs: Improved empty list message of google drive config. bzr revid: rpa@tinyerp.com-20130328062510-9239e59m6vpaef5f --- addons/google_docs/res_config_user_view.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/google_docs/res_config_user_view.xml b/addons/google_docs/res_config_user_view.xml index 860730cefee..1f19aafaca6 100644 --- a/addons/google_docs/res_config_user_view.xml +++ b/addons/google_docs/res_config_user_view.xml @@ -60,11 +60,11 @@

Click to add a new template.

- Link your google drive template to any record of OpenERP - You use to control the quality of your product in a spreadheet - and you review the delivery checklist for each delivery order in a foreign country. - To do it, you have really specific documents you want your collaborator fill in. - It is not an issue, here, feel free to add any template in OpenERP to link your specific documents to any records. + Link your google drive template to any record of OpenERP. + If you have really specific documents you want your collaborator fill in, + e.g. + Using a spreadsheet to control the quality of your product, reviewing the delivery checklist for each delivery order in a foreign country in a document... + Its very easy to manage them by adding a Google Drive template in OpenERP to link your specific document to any records.

From f3d3de20de66a798d928ee31afd462266a79ef46 Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Thu, 28 Mar 2013 12:42:12 +0530 Subject: [PATCH 060/315] [REF]: google_docs: Improved code for constraint bzr revid: rpa@tinyerp.com-20130328071212-kaim6d0oblhhq1a5 --- addons/google_docs/google_docs.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/addons/google_docs/google_docs.py b/addons/google_docs/google_docs.py index dd2d9062080..c33fbbde616 100644 --- a/addons/google_docs/google_docs.py +++ b/addons/google_docs/google_docs.py @@ -277,19 +277,13 @@ class config(osv.osv): } def _check_model_id(self, cr, uid, ids, context=None): - pool_id = self.browse(cr, uid, ids[0], context=context) - model_id = pool_id.model_id.id - filter_id = pool_id.filter_id.id - if model_id: - model_name = self.pool.get('ir.model').read(cr, uid, model_id, ['model']) - if filter_id: - filter = self.pool.get('ir.filters').read(cr, uid, filter_id, ['model_id']) - if model_name['model'] != filter['model_id']: - return False + config_id = self.browse(cr, uid, ids[0], context=context) + if config_id.filter_id.id and config_id.model_id.model != config_id.filter_id.model_id: + return False return True _constraints = [ - (_check_model_id, 'The model or filter chosen have not matched.', ['model_id','filter_id']), + (_check_model_id, 'Model of selected filter is not matching with model of current template.', ['model_id','filter_id']), ] config() From 0fdf9066ddb12b5058b055433b9b98e62189c83a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Thu, 28 Mar 2013 16:07:18 +0100 Subject: [PATCH 061/315] [FIX] point_of_sale: fixing potential timeout issues when sending orders over bad connection bzr revid: fva@openerp.com-20130328150718-zj91ljrlkvv59tkj --- addons/point_of_sale/static/src/js/db.js | 16 ++- addons/point_of_sale/static/src/js/models.js | 133 +++++++++++++------ 2 files changed, 109 insertions(+), 40 deletions(-) diff --git a/addons/point_of_sale/static/src/js/db.js b/addons/point_of_sale/static/src/js/db.js index a79b111b5c5..c28c08950db 100644 --- a/addons/point_of_sale/static/src/js/db.js +++ b/addons/point_of_sale/static/src/js/db.js @@ -267,11 +267,12 @@ function openerp_pos_db(instance, module){ return results; }, add_order: function(order){ - var last_id = this.load('last_order_id',0); + var order_id = this.load('last_order_id',0) + 1; var orders = this.load('orders',[]); - orders.push({id: last_id + 1, data: order}); - this.save('last_order_id',last_id+1); + orders.push({id: order_id, data: order}); + this.save('last_order_id', order_id); this.save('orders',orders); + return order_id; }, remove_order: function(order_id){ var orders = this.load('orders',[]); @@ -283,5 +284,14 @@ function openerp_pos_db(instance, module){ get_orders: function(){ return this.load('orders',[]); }, + get_order: function(order_id){ + var orders = this.get_orders(); + for(var i = 0, len = orders.length; i < len; i++){ + if(orders[i].id === order_id){ + return orders[i]; + } + } + return undefined; + }, }); } diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 660434ba53e..ac86ee852e0 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -120,7 +120,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal return self.fetch('res.currency',['symbol','position','rounding','accuracy'],[['id','=',self.get('company').currency_id[0]]]); }).then(function(currencies){ - console.log('Currency:',currencies[0]); self.set('currency',currencies[0]); return self.fetch('product.uom', null, null); @@ -256,12 +255,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal } }, - // saves the order locally and try to send it to the backend. 'record' is a bizzarely defined JSON version of the Order - push_order: function(record) { - this.db.add_order(record); - this.flush(); - }, - //creates a new empty order and sets it as the current order add_new_order: function(){ var order = new module.Order({pos:this}); @@ -269,45 +262,111 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal this.set('selectedOrder', order); }, + // saves the order locally and try to send it to the backend. 'record' is a bizzarely defined JSON version of the Order + // it returns a deferred that succeeds or fail when the pushed order is successfully posted on the server, previously failed orders + // will try to be re-sent but don't make this method return false if they fail. ( So that in the unlikely case of an order making + // the server crash, the other orders can still be sent ) + // payment process ) + push_order: function(record) { + var self = this; + var order_id = this.db.add_order(record); + var pushed = new $.Deferred(); + + this.set('nbr_pending_operations',self.db.get_orders().length); + + this.flush_mutex.exec(function(){ + + //first we try to push all orders (the one we added and the one that were not sent) + var tried_all = self._flush_all_orders(); + var done = new $.Deferred(); + + tried_all.always(function(){ + // then we verify that the one we just added has been sent successfuly. + self._flush_order(order_id) + .done( function(){ pushed.resolve();}) + .fail( function(){ pushed.reject(); }) + .always( function(){ done.resolve(); }); + }); + + return done; + }); + + return pushed; + }, + + // attemps to send all pending orders ( stored in the pos_db ) to the server, // and remove the successfully sent ones from the db once // it has been confirmed that they have been sent correctly. flush: function() { - //TODO make the mutex work - //this makes sure only one _int_flush is called at the same time - /* - return this.flush_mutex.exec(_.bind(function() { - return this._flush(0); - }, this)); - */ - this._flush(0); + var self = this; + var flushed = new $.Deferred(); + + this.flush_mutex.exec(function(){ + var done = new $.Deferred(); + + self._flush_all_orders() + .done( function(){ flushed.resolve();}) + .fail( function(){ flushed.reject(); }) + .always(function(){ done.resolve(); }); + + return done; + }); + + return flushed; }, - // attempts to send an order of index 'index' in the list of order to send. The index - // is used to skip orders that failed. do not call this method outside the mutex provided - // by flush() - _flush: function(index){ + + // attempts to send the locally stored order of id 'order_id' + // the sending is asynchronous and can take a long time to decide if it is successful or not (60s) + // it is therefore important to only call this method from inside a mutex + // this method returns a deferred indicating wether the sending was successful or not + _flush_order: function(order_id){ + var self = this; + var order = this.db.get_order(order_id); + + if(!order){ + // flushing a non existing order always succeeds + return (new $.Deferred()).resolve(); + } + + //we try to send the order. shadow prevents a spinner if it takes too long. + var rpc = (new instance.web.Model('pos.order')).call('create_from_ui',[[order]],undefined,{shadow: true, timeout: 2000}); + + rpc.fail(function(unused,event){ + //prevent an error popup creation by the rpc failure + event.preventDefault(); + console.error('Failed to send order:',order); + }); + + rpc.done(function(){ + self.db.remove_order(order_id); + self.set('nbr_pending_operations',self.db.get_orders().length); + }); + + return rpc; + }, + + // attempts to send all the locally stored orders. As with _flush_order, it should only be + // called from within a mutex. + // this method returns a deferred that always succeeds when all orders have been tried to be sent, + // even if none of them could actually be sent. + _flush_all_orders: function(){ var self = this; var orders = this.db.get_orders(); - self.set('nbr_pending_operations',orders.length); + var tried_all = new $.Deferred(); - var order = orders[index]; - if(!order){ - return; + function rec_flush(index){ + if(index < orders.length){ + self._flush_order(orders[index].id).always(function(){ + rec_flush(index+1); + }) + }else{ + tried_all.resolve(); + } } - //try to push an order to the server - // shadow : true is to prevent a spinner to appear in case of timeout - (new instance.web.Model('pos.order')).call('create_from_ui',[[order]],undefined,{ shadow:true }) - .fail(function(unused, event){ - //don't show error popup if it fails - event.preventDefault(); - console.error('Failed to send order:',order); - self._flush(index+1); - }) - .done(function(){ - //remove from db if success - self.db.remove_order(order.id); - self._flush(index); - }); + rec_flush(0); + + return tried_all; }, scan_product: function(parsed_ean){ From 96a74ae6ad1872a519cbe70d07fe2fbc00b40cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Thu, 28 Mar 2013 16:35:37 +0100 Subject: [PATCH 062/315] [IMP] point_of_sale: ... bzr revid: fva@openerp.com-20130328153537-ohdc3243lcu3dgbj --- addons/point_of_sale/static/src/js/models.js | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index ac86ee852e0..6a9d54ce608 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -294,7 +294,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal return pushed; }, - // attemps to send all pending orders ( stored in the pos_db ) to the server, // and remove the successfully sent ones from the db once // it has been confirmed that they have been sent correctly. From 703039f7c6cd660210e2d1cf4b59c19323557956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Thu, 28 Mar 2013 16:39:51 +0100 Subject: [PATCH 063/315] [IMP] web corelib: adding timeout option to the rpc api bzr revid: fva@openerp.com-20130328153951-om7hrs5l10oc0vm2 --- addons/web/static/src/js/corelib.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js index bfde707312c..c31b4ff5606 100644 --- a/addons/web/static/src/js/corelib.js +++ b/addons/web/static/src/js/corelib.js @@ -1011,6 +1011,9 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, { var deferred = $.Deferred(); if (! options.shadow) this.trigger('request', url, payload); + + if (options.timeout) + url.timeout = options.timeout; this.rpc_function(url, payload).then( function (response, textStatus, jqXHR) { From cae96ed4543abc9f05dbc4398a1832a1468639c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Fri, 29 Mar 2013 12:00:48 +0100 Subject: [PATCH 064/315] [FIX] point_of_sale: correctly set the customer on the order bzr revid: fva@openerp.com-20130329110048-1cx2sr4hp98cue0f --- addons/point_of_sale/point_of_sale.py | 3 ++- addons/point_of_sale/static/src/js/models.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 44139f7a499..9ee5b944718 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -489,7 +489,8 @@ class pos_order(osv.osv): 'user_id': order['user_id'] or False, 'session_id': order['pos_session_id'], 'lines': order['lines'], - 'pos_reference':order['name'] + 'pos_reference':order['name'], + 'partner_id': order['partner_id'] or False }, context) for payments in order['statement_ids']: diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 6a9d54ce608..426bea9a9b7 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -330,7 +330,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal //we try to send the order. shadow prevents a spinner if it takes too long. var rpc = (new instance.web.Model('pos.order')).call('create_from_ui',[[order]],undefined,{shadow: true, timeout: 2000}); - + rpc.fail(function(unused,event){ //prevent an error popup creation by the rpc failure event.preventDefault(); @@ -863,7 +863,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal lines: orderLines, statement_ids: paymentLines, pos_session_id: this.pos.get('pos_session').id, - partner_id: this.pos.get('client') ? this.pos.get('client').id : undefined, + partner_id: this.get_client() ? this.get_client().id : false, user_id: this.pos.get('cashier') ? this.pos.get('cashier').id : this.pos.get('user').id, }; }, From deb23a62b75e332e0b6a6f24df8b8c5d704ffc98 Mon Sep 17 00:00:00 2001 From: "Rajesh Prajapati (OpenERP)" Date: Mon, 1 Apr 2013 13:33:23 +0530 Subject: [PATCH 065/315] [IMP] google_docs : changes for code and rpa review 28 march bzr revid: rpr@tinyerp.com-20130401080323-vdw9rgdvzi0qyqrf --- addons/google_docs/google_docs.py | 138 +++++++------------- addons/google_docs/google_docs_demo.xml | 4 +- addons/google_docs/res_config_user_view.xml | 2 +- addons/google_docs/static/src/js/gdocs.js | 17 +-- 4 files changed, 58 insertions(+), 103 deletions(-) diff --git a/addons/google_docs/google_docs.py b/addons/google_docs/google_docs.py index c33fbbde616..3894eb7f318 100644 --- a/addons/google_docs/google_docs.py +++ b/addons/google_docs/google_docs.py @@ -86,31 +86,6 @@ class google_docs_ir_attachment(osv.osv): _logger.info('Logged into google docs as %s', user_config['user']) return client -# def create_empty_google_doc(self, cr, uid, res_model, res_id, context=None): -# '''Create a new google document, empty and with a default type (txt) -# :param res_model: the object for which the google doc is created -# :param res_id: the Id of the object for which the google doc is created -# :return: the ID of the google document object created -# ''' -# #login with the base account google module -# client = self._auth(cr, uid, context=context) -# # create the document in google docs -# title = "%s %s" % (context.get("name","Untitled Document."), datetime.today().strftime(DEFAULT_SERVER_DATETIME_FORMAT)) -# local_resource = gdata.docs.data.Resource(gdata.docs.data.SPREADSHEET_LABEL,title=title) -# #create a new doc in Google Docs -# gdocs_resource = client.post(entry=local_resource, uri='https://docs.google.com/feeds/default/private/full/') -# # create an ir.attachment into the db -# self.create(cr, uid, { -# 'res_model': res_model, -# 'res_id': res_id, -# 'type': 'url', -# 'name': title, -# 'url': gdocs_resource.get_alternate_link().href, -# }, context=context) -# return {'resource_id': gdocs_resource.resource_id.text, -# 'title': title, -# 'url': gdocs_resource.get_alternate_link().href} - def copy_gdoc(self, cr, uid, res_model, res_id, name_gdocs, gdoc_template_id, context=None): ''' copy an existing document in google docs @@ -139,7 +114,7 @@ class google_docs_ir_attachment(osv.osv): }, context=context) return copy_resource.resource_id.text - def google_doc_get(self, cr, uid, res_model, ids, context=None): + def get_google_docs_config(self, cr, uid, res_model, res_id, context=None): ''' Function called by the js, when no google doc are yet associated with a record, with the aim to create one. It will first seek for a google.docs.config associated with the model `res_model` to find out what's the template @@ -149,30 +124,28 @@ class google_docs_ir_attachment(osv.osv): :param res_model: the object for which the google doc is created :param ids: the list of ids of the objects for which the google doc is created. This list is supposed to have a length of 1 element only (batch processing is not supported in the code, though nothing really prevent it) - :return: the google document object created + :return: the config id and config name ''' - if len(ids) != 1: + if not res_id: raise osv.except_osv(_('Google Drive Error!'), _("Creating google drive may only be done by one at a time.")) - res_id = ids[0] pool_gdoc_config = self.pool.get('google.docs.config') - + # check if a model is configured with a template config_ids = pool_gdoc_config.search(cr, uid, [('model_id', '=', res_model)], context=context) - config = [] - for config_id in config_ids: - action = pool_gdoc_config.browse(cr, uid, config_id, context=context) - if action.filter_id: - google_doc_configs = self._filt(cr, uid, action, action.filter_id, res_id, context=context) + configs = [] + for config in pool_gdoc_config.browse(cr, uid, config_ids, context=context): + if config.filter_id: + google_doc_configs = self._filter(cr, uid, config, config.filter_id, res_id, context=context) if google_doc_configs: - config.append(action.name) + configs.append({'id': config.id, 'name': config.name}) else: - config.append(action.name) - return config + configs.append({'id': config.id, 'name': config.name}) + return configs - def _filt(self, cr, uid, action, action_filter, record_ids, context=None): + def _filter(self, cr, uid, action, action_filter, record_ids, context=None): """ filter the list record_ids that satisfy the action filter """ records = {} if record_ids and action_filter: - if not action.model_id.model == action_filter.model_id: + if not action.model_id == action_filter.model_id: raise osv.except_osv(_('Warning!'), _("Something went wrong with the configuration of attachments with google drive.Please contact your Administrator to fix the problem.")) model = self.pool.get(action_filter.model_id) domain = [('id', 'in', [record_ids])] + eval(action_filter.domain) @@ -181,36 +154,43 @@ class google_docs_ir_attachment(osv.osv): record_ids = model.search(cr, uid, domain, context=ctx) return record_ids - def get_attachment(self, cr, uid, res_model, rec_name, ids, context=None): - res_id = ids[0] + def get_google_attachment(self, cr, uid, config_id, res_id, context=None): pool_gdoc_config = self.pool.get('google.docs.config') - config_ids = pool_gdoc_config.search(cr, uid, [('model_id', '=', res_model),('name','=',rec_name['label'])], context=context)[0] - action = pool_gdoc_config.browse(cr, uid, config_ids, context=context) - attachment = {} - model_fields_dic = self.pool.get(res_model).read(cr, uid, res_id, [], context=context) - if model_fields_dic['name']: - model_fields_dic['name'] = model_fields_dic['name'].replace(' ','-') - # check if a model is configured with a template - if config_ids: - name_gdocs = action.name_template + pool_model = self.pool.get("ir.model") + attachment = {'url': False} + config = pool_gdoc_config.browse(cr, uid, config_id, context=context) + if config: + res_model = config.model_id + model_ids = pool_model.search(cr, uid, [('model','=',res_model)]) + if not model_ids: + return attachment + model = pool_model.browse(cr, uid, model_ids[0], context=context) + record = self.pool.get(res_model).browse(cr, uid, res_id, context=context) + filter_name = config.filter_id and config.filter_id.name or False + name_gdocs = config.name_template or "%(name)s_%(model)s_%(filter)s_gdrive" try: - name_gdocs = name_gdocs % model_fields_dic + name_gdocs = name_gdocs % {'name': record.name, 'model': model.name, 'filter': filter_name} except: raise osv.except_osv(_('Key Error!'), _("Your Google Doc Name Pattern's key does not found in object.")) - - attach_ids = self.search(cr, uid, [('res_model','=',res_model),('name','=',name_gdocs),('res_id','=',res_id)]) - if not attach_ids: - google_template_id = action.gdocs_resource_id - self.copy_gdoc(cr, uid, action.model_id.model, res_id, name_gdocs, google_template_id, context=context) + attach_ids = self.search(cr, uid, [('res_model','=',res_model),('name','=',name_gdocs),('res_id','=',res_id)]) - attachments = self.browse(cr, uid, attach_ids, context)[0] - attachment['url'] = attachments.url + if not attach_ids: + google_template_id = config.gdocs_resource_id + attach_id = self.copy_gdoc(cr, uid, config.model_id, res_id, name_gdocs, google_template_id, context=context) + else: + attach_id = attach_ids[0] + attachments = self.browse(cr, uid, attach_id, context) + attachment['url'] = attachments.url return attachment class config(osv.osv): _name = 'google.docs.config' _description = "Google Drive templates config" + def _list_all_models(self, cr, uid, context=None): + cr.execute("SELECT model, name from ir_model") + return cr.fetchall() + def _resource_get(self, cr, uid, ids, name, arg, context=None): result = {} for data in self.browse(cr, uid, ids, context): @@ -229,56 +209,30 @@ class config(osv.osv): raise osv.except_osv(_('Incorrect URL!'), _("Please enter a valid URL.")) return result - def _name_google_template_get(self, cr, uid, ids, name, arg, context=None): - res = {} - res_id = ids[0] - doc_pool = self.browse(cr, uid, ids[0], context) - label = doc_pool.name - res_model = doc_pool.model_id - res_fields_dic = self.pool.get(res_model.model).read(cr, uid, res_id, [], context=context) - doc_ids = self.search(cr, uid, [('model_id', '=', res_model.model),('name','=',label)], context=context)[0] - act = self.browse(cr, uid, doc_ids, context=context) - if doc_ids: - name_temp = act.name_template - if name_temp.find('model')!=-1: - name_temp = name_temp.replace('model',act.model_id.name) - res[doc_pool.id] = name_temp - if name_temp.find('filter')!=-1: - if act.filter_id: - name_temp = name_temp.replace('filter',act.filter_id.name) - res[doc_pool.id] = name_temp - else: - name_temp = name_temp.replace('_filter',"") - res[doc_pool.id] = name_temp - return res - _columns = { 'name' : fields.char('Template Name', required=True, size=1024), - 'model_id': fields.many2one('ir.model', 'Model', required=True), + 'model_id': fields.selection(_list_all_models, 'Model', required=True), 'filter_id' : fields.many2one('ir.filters', 'Filter'), 'gdocs_template_url': fields.char('Template URL', required=True, size=1024), 'gdocs_resource_id' : fields.function(_resource_get,type="char" ,string='Resource Id',store=True), - 'name_template': fields.function(_name_google_template_get,type="char", string='Google Drive Name Pattern', help='Choose how the new google drive will be named, on google side. Eg. gdoc_%(field_name)s',store=True), + 'name_template': fields.char('Google Drive Name Pattern', size=64, help='Choose how the new google drive will be named, on google side. Eg. gdoc_%(field_name)s', required=True), } def onchange_model_id(self, cr, uid, ids, model_id, context=None): - res = {'domain':{'filter_id':[]}} + res = {} if model_id: - model_name = self.pool.get('ir.model').read(cr, uid, model_id, ['model']) - if model_name: - mod_name = model_name['model'] - res['domain'] = {'filter_id': [('model_id', '=', mod_name)]} + res['domain'] = {'filter_id': [('model_id', '=', model_id), ('user_id','=',False)]} else: - res['value'] = {'filter_id': False} + res['value'] = {'filter_id': [('user_id','=',False)]} return res _defaults = { - 'name_template': '%(name)s_model_filter_gdoc', + 'name_template': '%(name)s_%(model)s_%(filter)s_gdrive', } def _check_model_id(self, cr, uid, ids, context=None): config_id = self.browse(cr, uid, ids[0], context=context) - if config_id.filter_id.id and config_id.model_id.model != config_id.filter_id.model_id: + if config_id.filter_id.id and config_id.model_id != config_id.filter_id.model_id: return False return True diff --git a/addons/google_docs/google_docs_demo.xml b/addons/google_docs/google_docs_demo.xml index 36e5f4fb227..b877e45aefa 100644 --- a/addons/google_docs/google_docs_demo.xml +++ b/addons/google_docs/google_docs_demo.xml @@ -14,10 +14,10 @@ Sales Department Opportunities - + crm.lead https://docs.google.com/spreadsheet/ccc?key=0Ah2qnrLAoZmUdGRvdVdmS1VoSDctWk1kd18taGZ4ckE#gid=0 - lead_sales-department_%(name)s_review + %(name)s_%(model)s_%(filter)s_gdrive diff --git a/addons/google_docs/res_config_user_view.xml b/addons/google_docs/res_config_user_view.xml index 1f19aafaca6..a874d802c98 100644 --- a/addons/google_docs/res_config_user_view.xml +++ b/addons/google_docs/res_config_user_view.xml @@ -25,7 +25,7 @@