From a9f28388ccd4df65ca9120155ab008672c1e8520 Mon Sep 17 00:00:00 2001 From: Naresh Choksy Date: Mon, 4 May 2009 17:42:54 +0530 Subject: [PATCH 01/20] modified:account reports to be compatible with new report engine bzr revid: nch@tinyerp.com-20090504121254-2jrmpttooc6snnde --- addons/account/report/general_journal.py | 6 ++-- addons/account/report/general_ledger.py | 4 +-- addons/account/report/partner_balance.py | 6 ++-- addons/account/report/third_party_ledger.py | 38 ++++++++++----------- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/addons/account/report/general_journal.py b/addons/account/report/general_journal.py index 9aa8b45aa10..926c3603e49 100644 --- a/addons/account/report/general_journal.py +++ b/addons/account/report/general_journal.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved # $Id$ # @@ -40,8 +40,8 @@ class journal_print(report_sxw.rml_parse): 'sum_credit': self._sum_credit }) - def preprocess(self, objects, datas, ids): - super(journal_print, self).preprocess(objects, datas, ids) + def set_context(self, objects, data, ids, report_type = None): + super(journal_print, self).set_context(objects, data, ids, report_type) self.cr.execute('select period_id, journal_id from account_journal_period where id in (' + ','.join([str(id) for id in ids]) + ')') res = self.cr.fetchall() self.period_ids = ','.join([str(x[0]) for x in res]) diff --git a/addons/account/report/general_ledger.py b/addons/account/report/general_ledger.py index 34c74df08c6..f9c2f30c0e1 100644 --- a/addons/account/report/general_ledger.py +++ b/addons/account/report/general_ledger.py @@ -39,7 +39,7 @@ class general_ledger(rml_parse.rml_parse): - def preprocess(self, objects, data, ids): + def set_context(self, objects, data, ids, report_type = None): ## @@ -55,7 +55,7 @@ class general_ledger(rml_parse.rml_parse): objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) - super(general_ledger, self).preprocess(objects, data, new_ids) + super(general_ledger, self).set_context(objects, data, ids, report_type) def __init__(self, cr, uid, name, context): super(general_ledger, self).__init__(cr, uid, name, context) diff --git a/addons/account/report/partner_balance.py b/addons/account/report/partner_balance.py index 451ad7bf744..4551aca1ed4 100755 --- a/addons/account/report/partner_balance.py +++ b/addons/account/report/partner_balance.py @@ -147,7 +147,7 @@ class partner_balance(report_sxw.rml_parse): else: return self.comma_me(new) - def preprocess(self, objects, data, ids): + def set_context(self, objects, data, ids, report_type = None): # Transformation des date # # @@ -168,7 +168,7 @@ class partner_balance(report_sxw.rml_parse): self.date_lst_string ='' if self.date_lst: self.date_lst_string = '\'' + '\',\''.join(map(str,self.date_lst)) + '\'' - + ## Compute Code account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') @@ -189,7 +189,7 @@ class partner_balance(report_sxw.rml_parse): "AND a.active", (data['form']['company_id'],)) self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()]) - super(partner_balance, self).preprocess(objects, data, ids) + super(partner_balance, self).set_context(objects, data, ids, report_type) def lines(self,data): diff --git a/addons/account/report/third_party_ledger.py b/addons/account/report/third_party_ledger.py index bf56470df3f..3004beddd7e 100644 --- a/addons/account/report/third_party_ledger.py +++ b/addons/account/report/third_party_ledger.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved # $Id$ # @@ -138,7 +138,7 @@ class third_party_ledger(rml_parse.rml_parse): string_map = date_string + ',' return string_map - def preprocess(self, objects, data, ids): + def set_context(self, objects, data, ids, report_type = None): PARTNER_REQUEST = '' if (data['model'] == 'res.partner'): ## Si on imprime depuis les partenaires @@ -160,7 +160,7 @@ class third_party_ledger(rml_parse.rml_parse): self.transform_period_into_date_array(data) elif data['form']['state'] == 'all': self.transform_both_into_date_array(data) - + self.date_lst_string = '' if self.date_lst: self.date_lst_string = '\'' + '\',\''.join(map(str,self.date_lst)) + '\'' @@ -182,12 +182,12 @@ class third_party_ledger(rml_parse.rml_parse): 'AND a.type IN ' + self.ACCOUNT_TYPE + " " \ "AND a.active", (data['form']['company_id'],)) self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()]) - + account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') partner_to_use = [] if self.date_lst and data['form']['soldeinit'] : - + self.cr.execute( "SELECT DISTINCT line.partner_id " \ "FROM account_move_line AS line, account_account AS account " \ @@ -202,7 +202,7 @@ class third_party_ledger(rml_parse.rml_parse): "AND account.active " , (self.date_lst[0],self.date_lst[len(self.date_lst)-1],data['form']['company_id'])) # else: -# +# # self.cr.execute( # "SELECT DISTINCT line.partner_id " \ # "FROM account_move_line AS line, account_account AS account " \ @@ -214,16 +214,16 @@ class third_party_ledger(rml_parse.rml_parse): # "AND account.company_id = %s " \ # "AND account.active " , # (data['form']['company_id'])) - + res = self.cr.dictfetchall() - + for res_line in res: partner_to_use.append(res_line['partner_id']) new_ids = partner_to_use - + self.partner_ids = ','.join(map(str, new_ids)) objects = self.pool.get('res.partner').browse(self.cr, self.uid, new_ids) - super(third_party_ledger, self).preprocess(objects, data, new_ids) + super(third_party_ledger, self).set_context(objects, data, new_ids, report_type) def lines(self, partner,data): account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') @@ -232,9 +232,9 @@ class third_party_ledger(rml_parse.rml_parse): RECONCILE_TAG = " " else: RECONCILE_TAG = "AND l.reconcile_id IS NULL" - + # if data['form']['soldeinit'] : -# +# # self.cr.execute( # "SELECT l.id,l.date,j.code, l.ref, l.name, l.debit, l.credit " \ # "FROM account_move_line l " \ @@ -271,8 +271,8 @@ class third_party_ledger(rml_parse.rml_parse): sum = r['debit'] - r['credit'] r['progress'] = sum full_account.append(r) - - return full_account + + return full_account def _sum_debit_partner(self, partner,data): @@ -306,7 +306,7 @@ class third_party_ledger(rml_parse.rml_parse): " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ") " , (partner.id,)) - + contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 @@ -336,7 +336,7 @@ class third_party_ledger(rml_parse.rml_parse): else: result_tmp = result_tmp + 0.0 - if self.date_lst_string: + if self.date_lst_string: self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line " \ @@ -345,7 +345,7 @@ class third_party_ledger(rml_parse.rml_parse): " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ") " , (partner.id,)) - + contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 @@ -386,7 +386,7 @@ class third_party_ledger(rml_parse.rml_parse): " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ") " ) - + contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 @@ -419,7 +419,7 @@ class third_party_ledger(rml_parse.rml_parse): result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 - + if self.date_lst_string: self.cr.execute( "SELECT sum(credit) " \ From 96d6ca40fca69c62441674f782c64c7233cda092 Mon Sep 17 00:00:00 2001 From: Naresh Choksy Date: Tue, 5 May 2009 11:59:15 +0530 Subject: [PATCH 02/20] bugfix:Auction reports bzr revid: nch@tinyerp.com-20090505062915-osursaptzlvbf9qq --- addons/auction/report/catalog2.py | 43 ++++++++++++++++++++++-------- addons/auction/report/catalog2.xsl | 6 ++--- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/addons/auction/report/catalog2.py b/addons/auction/report/catalog2.py index 8887224c746..00b5063bf07 100644 --- a/addons/auction/report/catalog2.py +++ b/addons/auction/report/catalog2.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved # $Id$ # @@ -37,8 +37,29 @@ import wizard import photo_shadow from tools import config -def escape(s): - return str(s or '').replace('
','').decode('latin1','replace').encode('utf-8') +def _to_unicode(s): + try: + return s.decode('utf-8') + except UnicodeError: + try: + return s.decode('latin') + except UnicodeError: + try: + return s.encode('ascii') + except UnicodeError: + return s + +def _to_decode(s): + try: + return s.encode('utf-8') + except UnicodeError: + try: + return s.encode('latin') + except UnicodeError: + try: + return s.decode('ascii') + except UnicodeError: + return s class auction_catalog(report_rml): @@ -71,22 +92,22 @@ class auction_catalog(report_rml): # name emelment key = 'name' categ = doc.createElement(key) - categ.appendChild(doc.createTextNode(escape(res[0]["name"]))) + categ.appendChild(doc.createTextNode(_to_decode(res[0]["name"]))) catalog.appendChild(categ) #Auctuion Date element categ = doc.createElement("AuctionDate1") - categ.appendChild(doc.createTextNode(escape(res[0]['auction1']))) + categ.appendChild(doc.createTextNode(_to_decode(res[0]['auction1']))) catalog.appendChild(categ) # Action Date 2 element categ = doc.createElement("AuctionDate2") - categ.appendChild(doc.createTextNode(escape(res[0]['auction2']))) + categ.appendChild(doc.createTextNode(_to_decode(res[0]['auction2']))) catalog.appendChild(categ) # promotion element promo = doc.createElement('promotion1') - + fp = file(config['addons_path']+'/auction/report/images/flagey_logo.jpg','r') file_data = fp.read() promo.appendChild(doc.createTextNode(base64.encodestring(file_data))) @@ -113,15 +134,15 @@ class auction_catalog(report_rml): products.appendChild(product) if cat['obj_desc']: infos = doc.createElement('infos') - lines = re.split('
|\n', unicode(cat['obj_desc'],'utf-8').encode('latin1')) + lines = re.split('
|\n', _to_unicode(cat['obj_desc'])) for line in lines: xline = doc.createElement('info') - xline.appendChild(doc.createTextNode(escape(line.decode('latin-1','replace').encode('utf-8')))) + xline.appendChild(doc.createTextNode(_to_decode(line))) infos.appendChild(xline) product.appendChild(infos) if cat['lot_num']: lnum = doc.createElement('lot_num') - lnum.appendChild(doc.createTextNode(escape(cat['lot_num']))) + lnum.appendChild(doc.createTextNode(_to_decode(str(cat['lot_num'])))) infos.appendChild(lnum) if cat['image']: @@ -146,7 +167,7 @@ class auction_catalog(report_rml): for key in ('lot_est1','lot_est2'): ref2 = doc.createElement(key) - ref2.appendChild(doc.createTextNode( escape(cat[key] or 0.0))) + ref2.appendChild(doc.createTextNode( _to_decode(str(cat[key] or 0.0)))) product.appendChild(ref2) oldlength = length length += 2.0 diff --git a/addons/auction/report/catalog2.xsl b/addons/auction/report/catalog2.xsl index b2794ec6763..8124a1f2a6b 100755 --- a/addons/auction/report/catalog2.xsl +++ b/addons/auction/report/catalog2.xsl @@ -11,8 +11,8 @@ - - + + 1cm 3.0cm 20cm 3.0cm Hotel des ventes Flagey @@ -30,7 +30,7 @@ -- +- Vente antiquitée le     --> From 5b71954f9f260b9cbc055c121bd9642295608466 Mon Sep 17 00:00:00 2001 From: Naresh Choksy Date: Wed, 6 May 2009 11:14:51 +0530 Subject: [PATCH 03/20] bugfix:372437 bzr revid: nch@tinyerp.com-20090506054451-foecxxx7i0mwyeim --- addons/sale_delivery_report/report/shipping.rml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/sale_delivery_report/report/shipping.rml b/addons/sale_delivery_report/report/shipping.rml index 0fdc7583058..7b02c71c7f8 100644 --- a/addons/sale_delivery_report/report/shipping.rml +++ b/addons/sale_delivery_report/report/shipping.rml @@ -115,6 +115,7 @@ Invoiced to + [[ o.sale_id and o.sale_id.partner_invoice_id and o.sale_id.partner_invoice_id.partner_id.name or '']] [[ o.sale_id and o.sale_id.partner_invoice_id and o.sale_id.partner_invoice_id.name or '']] [[ o.sale_id and o.sale_id.partner_invoice_id and o.sale_id.partner_invoice_id.street or '']] [[ o.sale_id and o.sale_id.partner_invoice_id and o.sale_id.partner_invoice_id.zip or '']] @@ -122,6 +123,7 @@ [[ o.sale_id and o.sale_id.partner_invoice_id and o.sale_id.partner_invoice_id.country_id and o.sale_id.partner_invoice_id.country_id.name or '']] + [[ o.sale_id and o.sale_id.partner_shipping_id and o.sale_id.partner_shipping_id.partner_id.name or '']] [[ o.sale_id and o.sale_id.partner_shipping_id and o.sale_id.partner_shipping_id.name or '']] [[ o.sale_id and o.sale_id.partner_shipping_id and o.sale_id.partner_shipping_id.street or '']] [[ o.sale_id and o.sale_id.partner_shipping_id and o.sale_id.partner_shipping_id.zip or '']] From b0243644e558744c09b5f0156ac662a5552fc8c6 Mon Sep 17 00:00:00 2001 From: Fabian Semal Date: Wed, 6 May 2009 11:24:15 +0200 Subject: [PATCH 04/20] base contact - Improvement (main job) bzr revid: fabian@tinyerp.com-20090506092415-b8wpoe9q4rwghogu --- addons/base_contact/base_contact.py | 4 +- addons/base_contact/base_contact_view.xml | 68 ++++++++++++----------- 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/addons/base_contact/base_contact.py b/addons/base_contact/base_contact.py index f06fe81dfa7..1729f086122 100644 --- a/addons/base_contact/base_contact.py +++ b/addons/base_contact/base_contact.py @@ -46,7 +46,8 @@ class res_partner_contact(osv.osv): 'birthdate':fields.date('Birth Date'), 'active' : fields.boolean('Active'), 'partner_id':fields.related('job_ids','address_id','partner_id',type='many2one', relation='res.partner', string='Main Employer'), - 'function_id':fields.related('job_ids','function_id',type='many2one', relation='res.partner.function', string='Main Job'), + 'function_id':fields.related('job_ids','function_id',type='many2one', relation='res.partner.function', string='Main Function'), + 'job_id':fields.related('job_ids',type='many2one', relation='res.partner.job', string='Main Job'), 'email': fields.char('E-Mail', size=240), } _defaults = { @@ -87,6 +88,7 @@ class res_partner_address(osv.osv): _inherit='res.partner.address' _description ='Partner Address' _columns = { + 'job_id':fields.related('job_ids','contact_id','job_id',type='many2one', relation='res.partner.job', string='Main Job'), 'job_ids':fields.one2many('res.partner.job', 'address_id', 'Contacts'), } res_partner_address() diff --git a/addons/base_contact/base_contact_view.xml b/addons/base_contact/base_contact_view.xml index 2298334ca7a..9b2a9c179fc 100644 --- a/addons/base_contact/base_contact_view.xml +++ b/addons/base_contact/base_contact_view.xml @@ -40,6 +40,7 @@ +
@@ -153,42 +154,42 @@ - - res.partner.form - form - res.partner - - - - - - + + res.partner.form + form + res.partner + + + + + + - - res.partner.form - form - res.partner - - - - - + + res.partner.form + form + res.partner + + + + + - - res.partner.form - form - res.partner - - - - - - - - - - + + res.partner.form + form + res.partner + + + + + + + + + + @@ -268,6 +269,7 @@ + From f523cc99949034505eeb9bebc79f61f0a1e11f4d Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Thu, 7 May 2009 11:43:43 +0530 Subject: [PATCH 05/20] [FIX] Bug 373080 : corrected psql view definition bzr revid: jvo@tinyerp.com-20090507061343-qdl6ym1igvwxw6k9 --- addons/report_timesheet/report_timesheet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/report_timesheet/report_timesheet.py b/addons/report_timesheet/report_timesheet.py index 3bea79c5289..939adab7f88 100644 --- a/addons/report_timesheet/report_timesheet.py +++ b/addons/report_timesheet/report_timesheet.py @@ -135,7 +135,7 @@ class report_timesheet_invoice(osv.osv): l.account_id as account_id, a.user_id as manager_id, sum(l.unit_amount) as quantity, - sum(l.unit_amount * t.list_price) as revenue + sum(l.unit_amount * t.list_price) as amount_invoice from account_analytic_line l left join hr_timesheet_invoice_factor f on (l.to_invoice=f.id) left join account_analytic_account a on (l.account_id=a.id) From af7966c8c3773918b138f4580ee963a43f65e56d Mon Sep 17 00:00:00 2001 From: Naresh Choksy Date: Thu, 7 May 2009 14:56:42 +0530 Subject: [PATCH 06/20] improved product pricelist report bzr revid: nch@tinyerp.com-20090507092642-nr4q1uasap4ybvoc --- addons/product/report/product_pricelist.rml | 155 +++++++++++++------- 1 file changed, 100 insertions(+), 55 deletions(-) diff --git a/addons/product/report/product_pricelist.rml b/addons/product/report/product_pricelist.rml index 473920f6535..7bf31a4fb05 100644 --- a/addons/product/report/product_pricelist.rml +++ b/addons/product/report/product_pricelist.rml @@ -19,6 +19,7 @@ + @@ -32,23 +33,70 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + - + - - + + @@ -59,14 +107,15 @@ - - + + + @@ -84,49 +133,49 @@ - + Products Price List - - + - + + + + + - Price List Name: + Price List Name: - [[ get_pricelist(data['form']['price_list']) ]] + [[ get_pricelist(data['form']['price_list']) ]] - Currency : + Currency : - [[ get_currency ( data['form']['price_list']) ]] + [[ get_currency ( data['form']['price_list']) ]] - Printing Date : + Printing Date : - [[ formatLang(time.strftime('%Y-%m-%d'), date=True) ]] - - - + [[ formatLang(time.strftime('%Y-%m-%d'), date=True) ]] - + - + Description @@ -148,37 +197,33 @@ - - - - - [[repeatIn(get_categories(objects,data['form']), 'c')]][[ c['name'] ]] - - - - - [[repeatIn(c['products'], 'p')]][[ p['code'] and '[' + p['code'] + '] ' or '' ]] [[ p['name'] ]] - - - [[p['qty1'] ]] - - - [[ p['qty2'] ]] - - - [[ p['qty3'] ]] - - - [[ p['qty4'] ]] - - - [[ p['qty5'] ]] - - - - - - +
+ + [[repeatIn(get_categories(objects,data['form']), 'c')]][[ c['name'] ]] + + + + [[repeatIn(c['products'], 'p')]][[ p['code'] and '[' + p['code'] + '] ' or '' ]] [[ p['name'] ]] + + + [[p['qty1'] ]] + + + [[ p['qty2'] ]] + + + [[ p['qty3'] ]] + + + [[ p['qty4'] ]] + + + [[ p['qty5'] ]] + + + +
+ From b66c44f96531e7fe817d583f622f00f5fe6e9760 Mon Sep 17 00:00:00 2001 From: Naresh Choksy Date: Thu, 7 May 2009 15:05:22 +0530 Subject: [PATCH 07/20] Bugfix:partner_ledger report when no records exists bzr revid: nch@tinyerp.com-20090507093522-rdf3pakqahq1uhm3 --- .../wizard/wizard_third_party_ledger.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/addons/account/wizard/wizard_third_party_ledger.py b/addons/account/wizard/wizard_third_party_ledger.py index 749e2f66396..8d7a46868ed 100755 --- a/addons/account/wizard/wizard_third_party_ledger.py +++ b/addons/account/wizard/wizard_third_party_ledger.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved # $Id$ # @@ -28,7 +28,7 @@ from tools.translate import _ period_form = ''' - + @@ -53,7 +53,7 @@ period_form = ''' - + ''' period_fields = { @@ -85,7 +85,7 @@ period_fields = { class wizard_report(wizard.interface): - + def _get_defaults(self, cr, uid, data, context): fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear') data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid) @@ -104,9 +104,9 @@ class wizard_report(wizard.interface): data['form']['reconcil'] = False data['form']['soldeinit'] = True return data['form'] - + def _check_date(self, cr, uid, data, context): - + sql = """ SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where '%s' between f.date_start and f.date_stop """%(data['form']['date1']) cr.execute(sql) @@ -116,17 +116,18 @@ class wizard_report(wizard.interface): raise wizard.except_wizard(_('UserError'),_('Date to must be set between %s and %s') % (str(res[0]['date_start']) , str(res[0]['date_stop']))) else: return 'report' - else: raise wizard.except_wizard(_('UserError'),_('Date not in a defined fiscal year')) - - + def _check_state(self, cr, uid, data, context): if data['form']['state'] == 'bydate' or data['form']['state'] == 'all': data['form']['fiscalyear'] = False else : data['form']['fiscalyear'] = True self._check_date(cr, uid, data, context) + acc_id = pooler.get_pool(cr.dbname).get('account.invoice').search(cr, uid, [('state','=','open')]) + if not acc_id: + raise wizard.except_wizard(_('No Data Available'), _('No records found for your selection!')) return data['form'] From e713f85c15b9e14e42d1cd7d85a1c8336e045aee Mon Sep 17 00:00:00 2001 From: "Harry (Open ERP)" Date: Thu, 7 May 2009 16:22:59 +0530 Subject: [PATCH 08/20] [IMP] report_intrastat : report base on invoice not stock move bzr revid: hmo@tinyerp.com-20090507105259-4i01zzgeje86aifl --- addons/report_intrastat/report_intrastat.py | 111 ++++++++++-------- .../report_intrastat_view.xml | 6 +- 2 files changed, 64 insertions(+), 53 deletions(-) diff --git a/addons/report_intrastat/report_intrastat.py b/addons/report_intrastat/report_intrastat.py index 6b467f08c41..c45ac1085ae 100644 --- a/addons/report_intrastat/report_intrastat.py +++ b/addons/report_intrastat/report_intrastat.py @@ -55,7 +55,9 @@ class report_intrastat(osv.osv): _description = "Intrastat report" _auto = False _columns = { - 'name': fields.date('Month', readonly=True), + 'name': fields.many2one('account.period', 'Period', readonly=True,select=True), + 'supply_units':fields.float('Supply Units', readonly=True), + 'ref':fields.char('Origin',size=64, readonly=True), 'code': fields.char('Country code', size="2", readonly=True), 'intrastat_id': fields.many2one('report.intrastat.code', 'Intrastat code', readonly=True), 'weight': fields.float('Weight', readonly=True), @@ -66,56 +68,63 @@ class report_intrastat(osv.osv): def init(self, cr): cr.execute(""" create or replace view report_intrastat as ( - select - to_char(m.create_date, 'YYYY-MM-01') as name, - min(m.id) as id, - pt.intrastat_id as intrastat_id, - case when l.usage in ('supplier', 'customer') then upper(pc.code) else upper(c.code) end as code, - sum(case when pol.price_unit is not null - then pol.price_unit * m.product_qty - else - case when sol.price_unit is not null - then sol.price_unit * m.product_qty - else 0 - end - end) as value, - sum(pt.weight_net * m.product_qty) as weight, - case when l.usage in ('supplier', 'customer') then 'import' else 'export' end as type, - case when ppl.currency_id is not null - then ppl.currency_id - else spl.currency_id - end as currency_id - from - stock_move m - left join (product_template pt - left join product_product pp on (pp.product_tmpl_id = pt.id)) - on (m.product_id = pt.id) - left join (res_partner_address a - left join res_country c on (c.id = a.country_id)) - on (a.id = m.address_id) - left join (stock_picking sp - left join (res_partner_address pa - left join res_country pc on (pc.id = pa.country_id)) - on (pa.id = sp.address_id)) - on (sp.id = m.picking_id) - left join stock_location l on (l.id = m.location_id) - left join stock_location dl on (dl.id = m.location_dest_id) - left join (purchase_order_line pol - left join (purchase_order po - left join product_pricelist ppl on (ppl.id = po.pricelist_id)) - on (po.id = pol.order_id)) - on (pol.id = m.purchase_line_id) - left join (sale_order_line sol - left join (sale_order so - left join product_pricelist spl on (spl.id = so.pricelist_id)) - on (so.id = sol.order_id)) - on (sol.id = m.sale_line_id) - where - m.state != 'draft' - and ((l.usage in ('supplier', 'customer') and dl.usage not in ('supplier', 'customer')) - or (dl.usage in ('supplier', 'customer') and l.usage not in ('supplier', 'customer'))) - and (c.intrastat is not null or pc.intrastat is not null) - group by to_char(m.create_date, 'YYYY-MM-01'), pt.intrastat_id, c.code, pc.code, l.usage, dl.usage, ppl.currency_id, spl.currency_id + select + inv.period_id as name, + min(inv_line.id) as id, + intrastat.id as intrastat_id, + upper(inv_country.code) as code, + sum(case when inv_line.price_unit is not null + then inv_line.price_unit * inv_line.quantity + else 0 + end) as value, + sum( + case when uom.category_id != puom.category_id then pt.weight_net * inv_line.quantity + else + case when uom.factor_inv_data > 0 + then + pt.weight_net * inv_line.quantity * uom.factor_inv_data + else + pt.weight_net * inv_line.quantity / uom.factor + end + end + ) as weight, + sum( + case when uom.category_id != puom.category_id then inv_line.quantity + else + case when uom.factor_inv_data > 0 + then + inv_line.quantity * uom.factor_inv_data + else + inv_line.quantity / uom.factor + end + end + ) as supply_units, + + inv.currency_id as currency_id, + inv.number as ref, + case when inv.type in ('out_invoice','in_refund') + then 'export' + else 'import' + end as type + from + account_invoice inv + left join account_invoice_line inv_line on inv_line.invoice_id=inv.id + left join (product_template pt + left join product_product pp on (pp.product_tmpl_id = pt.id)) + on (inv_line.product_id = pt.id) + left join product_uom uom on uom.id=inv_line.uos_id + left join product_uom puom on puom.id = pt.uom_id + left join report_intrastat_code intrastat on pt.intrastat_id = intrastat.id + left join (res_partner_address inv_address + left join res_country inv_country on (inv_country.id = inv_address.country_id)) + on (inv_address.id = inv.address_invoice_id) + + where + inv.state in ('open','paid') + and inv_line.product_id is not null + and inv_country.intrastat=true + + group by inv.period_id,intrastat.id,inv.type,pt.intrastat_id, inv_country.code,inv.number, inv.currency_id )""") report_intrastat() diff --git a/addons/report_intrastat/report_intrastat_view.xml b/addons/report_intrastat/report_intrastat_view.xml index 9432091beca..51841c13bb5 100644 --- a/addons/report_intrastat/report_intrastat_view.xml +++ b/addons/report_intrastat/report_intrastat_view.xml @@ -77,10 +77,12 @@ - + + + @@ -93,7 +95,7 @@ report.intrastat form tree - [('name','=',time.strftime('%Y-%m-01'))] + [('name','=',time.strftime('%b.%Y'))] From 8325ffdb14a1320375cdbe33da69aa46559e15b9 Mon Sep 17 00:00:00 2001 From: "Sofia (Open ERP)" Date: Fri, 8 May 2009 11:17:36 +0530 Subject: [PATCH 09/20] bugfixed bzr revid: sso@tinyerp.com-20090508054736-9kok0hlpf7ysht54 --- addons/base_contact/base_contact.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/base_contact/base_contact.py b/addons/base_contact/base_contact.py index 1729f086122..d0453a9f94b 100644 --- a/addons/base_contact/base_contact.py +++ b/addons/base_contact/base_contact.py @@ -100,7 +100,7 @@ class res_partner_job(osv.osv): return [] res = [] for r in self.browse(cr, uid, ids): - res.append((r.id, self.pool.get('res.partner.contact').name_get(cr, uid, [r.contact_id.id])[0][1] +", "+ r.function_id.name)) + res.append((r.id, self.pool.get('res.partner.contact').name_get(cr, uid, [r.contact_id.id])[0][1] +", %s"% r.function_id.name)) return res def search(self, cr, user, args, offset=0, limit=None, order=None, From 0bf456e96ae3c7d71d0439602c836ea6f0afe4eb Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Fri, 8 May 2009 11:27:04 +0530 Subject: [PATCH 10/20] [FIX] Bug 372583 : Supplier invoice creates partner as supplier only bzr revid: jvo@tinyerp.com-20090508055704-xgz0y55iux302gb2 --- addons/account/account_invoice_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 9715598eb9c..b48d4ab1606 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -141,7 +141,7 @@ - + From 806dcd00b85bf2ad298a93a0a3ec3803ed92433a Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Fri, 8 May 2009 12:25:06 +0530 Subject: [PATCH 11/20] [FIX] Bug 370854 : states defines for button and made stock.moves readonly(ref:SSI) bzr revid: jvo@tinyerp.com-20090508065506-mobnpkej9ddw79qp --- addons/stock/stock.py | 2 +- addons/stock/stock_view.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 35c39d6ceeb..638fb7ca658 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -425,7 +425,7 @@ class stock_picking(osv.osv): 'date_done':fields.datetime('Date Done'), 'max_date': fields.function(get_min_max_date, fnct_inv=_set_maximum_date, multi="min_max_date", method=True,store=True, type='datetime', string='Max. Planned Date', select=2), - 'move_lines': fields.one2many('stock.move', 'picking_id', 'Move lines'), + 'move_lines': fields.one2many('stock.move', 'picking_id', 'Move lines',states={'done':[('readonly',True)],'cancel':[('readonly',True)]}), 'auto_picking': fields.boolean('Auto-Packing'), 'address_id': fields.many2one('res.partner.address', 'Partner'), diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 65fa1fc504d..370a5b52f81 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -653,7 +653,7 @@