avanzosc team mailing list archive
-
avanzosc team
-
Mailing list archive
-
Message #00625
Re: [Merge] lp:~oihanecruce/avanzosc/nayar_contract_annexe_report into lp:~avanzosc-security-team/avanzosc/72horas
Review: Approve code review
Dos comentarios no bloqueantes, pero LGTM
Diff comments:
> === modified file 'nayar_contract_annexe_report/__init__.py'
> --- nayar_contract_annexe_report/__init__.py 2014-06-11 10:23:47 +0000
> +++ nayar_contract_annexe_report/__init__.py 2014-07-04 10:09:26 +0000
> @@ -18,7 +18,4 @@
> #
> ##############################################################################
>
> -import report
> -
> -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
> -
> +from . import report
>
> === modified file 'nayar_contract_annexe_report/__openerp__.py'
> --- nayar_contract_annexe_report/__openerp__.py 2014-06-11 10:23:47 +0000
> +++ nayar_contract_annexe_report/__openerp__.py 2014-07-04 10:09:26 +0000
> @@ -20,19 +20,18 @@
> ##############################################################################
>
> {
> - "name" : "Nayar Contract Annexe Report",
> - "version" : "1.0",
> - "author" : "Nayar Systems",
> + "name": "Nayar Contract Annexe Report",
> + "version": "1.0",
> + "author": "Nayar Systems",
> "category" : "Enterprise Specific Modules",
> - "description":"Module to print contract annexe with custom format.",
> - "depends" : ["dos_contracts"],
> - "init_xml" : [],
> - "demo_xml" : [],
> - "update_xml" : [
> + "description": "Module to print contract annexe with custom format.",
> + "depends": [
> + "dos_contracts",
> + ],
> + "data" : [
> 'contract_annexe_report.xml',
> - ],
> + ],
> "website": 'http://www.72horas.net',
> "active": False,
> "installable": True,
> }
> -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
>
> === modified file 'nayar_contract_annexe_report/report/__init__.py'
> --- nayar_contract_annexe_report/report/__init__.py 2014-06-11 10:23:47 +0000
> +++ nayar_contract_annexe_report/report/__init__.py 2014-07-04 10:09:26 +0000
> @@ -18,7 +18,4 @@
> #
> ##############################################################################
>
> -import contract_annexe
> -
> -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
> -
> +from . import contract_annexe
>
> === modified file 'nayar_contract_annexe_report/report/contract_annexe.py'
> --- nayar_contract_annexe_report/report/contract_annexe.py 2014-06-11 10:23:47 +0000
> +++ nayar_contract_annexe_report/report/contract_annexe.py 2014-07-04 10:09:26 +0000
> @@ -21,14 +21,14 @@
>
> import time
> from datetime import datetime
> -from report import report_sxw
> -from osv import osv
> -from tools.translate import _
> -import pooler
> -
> -class contract_annexe_report(report_sxw.rml_parse):
> - def __init__(self, cr, uid, name, context):
> - super(contract_annexe_report, self).__init__(cr, uid, name, context=context)
> +from openerp.report import report_sxw
> +from openerp.tools.translate import _
> +
> +
> +class ContractAnnexeReport(report_sxw.rml_parse):
> + def __init__(self, cr, uid, name, context=None):
> + super(ContractAnnexeReport, self).__init__(cr, uid, name,
> + context=context)
> self.localcontext.update({
> 'time': time,
> 'get_shippings': self.get_shippings,
> @@ -61,134 +61,159 @@
>
> return list(shippings)
>
> - def get_contract(self, num_annexe_ship):
> - annexe_ids = self.pool.get('contract.annexe').search(self.cr, self.uid, [('num_annexe_ship', '=', num_annexe_ship)])
> + def get_contract(self, shipping):
> + annexe_obj = self.pool['contract.annexe']
> + annexe_ids = annexe_obj.search(self.cr, self.uid,
> + [('num_annexe_ship', '=', shipping)])
> if annexe_ids:
> - return self.pool.get('contract.annexe').browse(self.cr, self.uid, annexe_ids[0]).contract_id
> + return annexe_obj.browse(self.cr, self.uid,
> + annexe_ids[0]).contract_id
> else:
> return None
>
> def get_shipping_date(self, shipping):
> - annexe_ids = self.pool.get('contract.annexe').search(self.cr, self.uid, [('num_annexe_ship', '=', shipping)])
> + annexe_obj = self.pool['contract.annexe']
> + annexe_ids = annexe_obj.search(self.cr, self.uid,
> + [('num_annexe_ship', '=', shipping)])
> if annexe_ids:
> - date = self.pool.get('contract.annexe').browse(self.cr, self.uid, annexe_ids[0]).annexe_date
> - return datetime.strptime(date[0:10], '%Y-%m-%d').strftime('%d/%m/%Y')
> + date = annexe_obj.browse(self.cr, self.uid,
> + annexe_ids[0]).annexe_date
> + return datetime.strptime(date[0:10],
> + '%Y-%m-%d').strftime('%d/%m/%Y')
> else:
> return None
>
> def get_shipping_formated_date(self, shipping):
> - annexe_ids = self.pool.get('contract.annexe').search(self.cr, self.uid, [('num_annexe_ship', '=', shipping)])
> + annexe_obj = self.pool['contract.annexe']
> + annexe_ids = annexe_obj.search(self.cr, self.uid,
> + [('num_annexe_ship', '=', shipping)])
> if annexe_ids:
> - date = self.pool.get('contract.annexe').browse(self.cr, self.uid, annexe_ids[0]).annexe_date
> + date = annexe_obj.browse(self.cr, self.uid,
> + annexe_ids[0]).annexe_date
> date = datetime.strptime(date[0:10], '%Y-%m-%d')
> - return str(date.day) + ' de ' + date.strftime('%B').capitalize() + ' de ' + str(date.year)
> + return (str(date.day) + ' de ' +
> + date.strftime('%B').capitalize() + ' de ' + str(date.year))
> else:
> return None
>
> -
> def get_left_text(self, contract):
> -
> text = ""
> -
> - partner = contract.transmitter_partner_id or (self.company and self.company.partner_id) or None
> -
> +
> + partner = (contract.transmitter_partner_id or
> + (self.company and self.company.partner_id) or None)
> +
> if partner:
> -
> # Nombre empresa
> text += partner.name or ""
> # CIF
> text += partner.vat and (" - " + partner.vat) or ""
> # Tomo
> - text += partner.es_tomo and (" - " + _("RM Tomo") + " " + partner.es_tomo) or ""
> + text += (partner.es_tomo and
> + (" - " + _("RM Tomo") + " " + partner.es_tomo) or "")
> # Libro
> - text += partner.es_libro and (" " + _("Libro") + " " + partner.es_libro) or ""
> + text += (partner.es_libro and
> + (" " + _("Libro") + " " + partner.es_libro) or "")
> # Folio
> - text += partner.es_folio and (" " + _("Folio") + " " + partner.es_folio) or ""
> + text += (partner.es_folio and
> + (" " + _("Folio") + " " + partner.es_folio) or "")
> # Hoja
> - text += partner.es_hoja and (" " + _("Hoja") + " " + partner.es_hoja) or ""
> + text += (partner.es_hoja and
> + (" " + _("Hoja") + " " + partner.es_hoja) or "")
> # Inscripcion
> - text += partner.es_registro_mercantil and (" " + _("Inscripción") + " " + partner.es_registro_mercantil) or ""
> + text += (partner.es_registro_mercantil and
> + (" " + _("Inscripción") + " " +
> + partner.es_registro_mercantil) or "")
> # Final
> - text += "."
> + text += "."
>
> return text
> -
> +
> def get_footer_text(self, contract):
> -
> + partner_obj = self.pool['res.partner']
> text = ""
> -
> - partner = contract.transmitter_partner_id or (self.company and self.company.partner_id) or None
> -
> +
> + partner = (contract.transmitter_partner_id or
> + (self.company and self.company.partner_id) or None)
> +
> if partner:
> -
> - addr_ids = self.pool.get('res.partner').address_get(self.cr, self.uid, [partner.id], ['default'])
> + addr_ids = partner_obj.address_get(self.cr, self.uid, [partner.id],
> + ['default'])
> addr_id = addr_ids['default']
> - addr = self.pool.get('res.partner.address').browse(self.cr, self.uid, addr_id)
> -
> + addr = partner_obj.browse(self.cr, self.uid, addr_id)
> +
> # Nombre empresa
> text += partner and partner.name or ""
> - # Calle empresa
> - text += addr and addr.street and (" - " + addr.street + ".") or ""
> - # Codigo Postal empresa
> - text += addr and addr.zip and (" - " + addr.zip) or ""
> - # Ciudad
> - text += addr and addr.city and (" " + addr.city) or ""
> - # Telefono
> - text += addr and addr.phone and (" - " + _("Tel.") + " " + addr.phone) or ""
> - # Fax
> - text += addr and addr.fax and (" - " + _("Fax.") + " " + addr.fax) or ""
> - # Email
> - text += addr and addr.email and (" - " + _("E-Mail") + " " + addr.email) or ""
> -
> + if addr:
> + # Calle empresa
> + text += addr.street and (" - " + addr.street + ".") or ""
> + # Codigo Postal empresa
> + text += addr.zip and (" - " + addr.zip) or ""
> + # Ciudad
> + text += addr.city and (" " + addr.city) or ""
> + # Telefono
> + text += (addr.phone and
> + (" - " + _("Tel.") + " " + addr.phone) or "")
> + # Fax
> + text += (addr.fax and
> + (" - " + _("Fax.") + " " + addr.fax) or "")
> + # Email
> + text += (addr.email and
> + (" - " + _("E-Mail") + " " + addr.email) or "")
> +
> return text
> -
> - def get_company_address (self, contract):
> -
> +
> + def get_company_address(self, contract):
> + partner_obj = self.pool['res.partner']
> res = []
> -
> - partner = contract.transmitter_partner_id or (self.company and self.company.partner_id) or None
> -
> +
> + partner = (contract.transmitter_partner_id or
> + (self.company and self.company.partner_id) or None)
> +
> if partner:
> -
> - addr_ids = self.pool.get('res.partner').address_get(self.cr, self.uid, [partner.id], ['default'])
> + addr_ids = partner_obj.address_get(self.cr, self.uid, [partner.id],
> + ['default'])
> addr_id = addr_ids['default']
> - addr = self.pool.get('res.partner.address').browse(self.cr, self.uid, addr_id)
> -
> + addr = partner_obj.browse(self.cr, self.uid, addr_id)
> +
> res.append(partner and partner.name or "")
> res.append((addr and addr.street) or '')
> - res.append((addr and addr.zip or '') + " - " + (addr and addr.city or ''))
> - res.append((addr and addr.state_id and addr.state_id.name or '') + " (" + (addr and addr.country_id and addr.country_id.name or '') + ")")
> + res.append((addr and addr.zip or '') + " - " +
> + (addr and addr.city or ''))
> + res.append((addr and addr.state_id and addr.state_id.name or '') +
> + " (" + (addr and addr.country_id and
> + addr.country_id.name or '') + ")")
> res.append(partner and partner.vat or '')
> -
> +
> else:
> -
> - res.append(" ")
> - res.append(" ")
> - res.append(" ")
> - res.append(" ")
> - res.append(" ")
> -
> + res.append(" ")
Se podría poner bucle.
> + res.append(" ")
> + res.append(" ")
> + res.append(" ")
> + res.append(" ")
> +
> return res
> -
> - def get_partner_address (self, contract):
> -
> +
> + def get_partner_address(self, contract):
> + partner_obj = self.pool['res.partner']
> res = []
> -
> +
> if contract.customer_id:
> -
> partner = contract.customer_id
> - addr_ids = self.pool.get('res.partner').address_get(self.cr, self.uid, [partner.id], ['default'])
> + addr_ids = partner_obj.address_get(self.cr, self.uid, [partner.id],
> + ['default'])
> addr_id = addr_ids['default']
> - addr = self.pool.get('res.partner.address').browse(self.cr, self.uid, addr_id)
> -
> + addr = partner_obj.browse(self.cr, self.uid, addr_id)
> +
> res.append(partner and partner.name or "")
> res.append((addr and addr.street) or '')
> - res.append((addr and addr.zip or '') + " - " + (addr and addr.city or ''))
> - res.append((addr and addr.state_id and addr.state_id.name or '') + " (" + (addr and addr.country_id and addr.country_id.name or '') + ")")
> + res.append((addr and addr.zip or '') + " - " +
> + (addr and addr.city or ''))
> + res.append((addr and addr.state_id and addr.state_id.name or '') +
> + " (" + (addr and addr.country_id and
> + addr.country_id.name or '') + ")")
> res.append(partner and partner.vat or '')
> -
> +
> else:
> -
> res.append(" ")
Se podría poner bucle
> res.append(" ")
> res.append(" ")
> @@ -196,29 +221,33 @@
> res.append(" ")
>
> return res
> -
> - def get_annexe_lines (self, shipping):
> -
> - annexe_obj = self.pool.get('contract.annexe')
> -
> +
> + def get_annexe_lines(self, shipping):
> + annexe_obj = self.pool['contract.annexe']
> res = []
> -
> - annexe_ids = annexe_obj.search(self.cr, self.uid, [('num_annexe_ship', '=', shipping)])
> -
> +
> + annexe_ids = annexe_obj.search(self.cr, self.uid,
> + [('num_annexe_ship', '=', shipping)])
> +
> for a in annexe_obj.browse(self.cr, self.uid, annexe_ids):
> annexe = {}
> -
> - annexe["phone"] = a.production_lot_id and a.production_lot_id.telefono or ''
> - annexe["icc"] = a.production_lot_id and a.production_lot_id.icc or ''
> - annexe["imei"] = a.production_lot_2_id and a.production_lot_2_id.imei or ''
> - annexe["link"] = a.production_lot_2_id and a.production_lot_2_id.product_id and a.production_lot_2_id.product_id.name or ''
> +
> + annexe["phone"] = (a.production_lot_id and
> + a.production_lot_id.telefono or '')
> + annexe["icc"] = (a.production_lot_id and
> + a.production_lot_id.icc or '')
> + annexe["imei"] = (a.production_lot_2_id and
> + a.production_lot_2_id.imei or '')
> + annexe["link"] = (a.production_lot_2_id and
> + a.production_lot_2_id.product_id and
> + a.production_lot_2_id.product_id.name or '')
>
> res.append(annexe)
> -
> +
> return res
>
>
> -class contract_annexe_cp_report(contract_annexe_report):
> +class ContractAnnexeCpReport(ContractAnnexeReport):
> def get_shippings(self, pickings_or_invoices):
> shippings = set()
>
> @@ -230,26 +259,37 @@
> lines = picking_or_invoice.invoice_line
>
> for line in lines:
> - if line.contract_annexe_id and line.contract_id.customer_id != line.contract_id.elevator_id:
> + if (line.contract_annexe_id and
> + (line.contract_id.customer_id !=
> + line.contract_id.elevator_id)):
> shippings.add(line.contract_annexe_id.num_annexe_ship)
>
> return list(shippings)
>
>
> -class contract_annexe_basic_report(contract_annexe_report):
> +class ContractAnnexeBasicReport(ContractAnnexeReport):
> def get_shippings(self, annexes):
> shippings = set()
> for annexe in annexes:
> shippings.add(annexe.num_annexe_ship)
> return list(shippings)
> -
> -report_sxw.report_sxw('report.contract.annexe.picking.report', 'stock.picking', 'addons/nayar_contract_annexe_report/report/contract_annexe.rml', parser=contract_annexe_report)
> -
> -report_sxw.report_sxw('report.contract.annexe.invoice.report', 'account.invoice', 'addons/nayar_contract_annexe_report/report/contract_annexe.rml', parser=contract_annexe_report)
> -
> -report_sxw.report_sxw('report.contract.annexe.invoice.cp.report', 'account.invoice', 'addons/nayar_contract_annexe_report/report/contract_annexe.rml', parser=contract_annexe_cp_report)
> -
> -report_sxw.report_sxw('report.contract.annexe.basic.report', 'contract.annexe', 'addons/nayar_contract_annexe_report/report/contract_annexe.rml', parser=contract_annexe_basic_report)
> -
> -
> -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
> +
> +report_sxw.report_sxw('report.contract.annexe.picking.report',
> + 'stock.picking',
> + 'addons/nayar_contract_annexe_report/report/contract_annexe.rml',
> + parser=ContractAnnexeReport)
> +
> +report_sxw.report_sxw('report.contract.annexe.invoice.report',
> + 'account.invoice',
> + 'addons/nayar_contract_annexe_report/report/contract_annexe.rml',
> + parser=ContractAnnexeReport)
> +
> +report_sxw.report_sxw('report.contract.annexe.invoice.cp.report',
> + 'account.invoice',
> + 'addons/nayar_contract_annexe_report/report/contract_annexe.rml',
> + parser=ContractAnnexeCpReport)
> +
> +report_sxw.report_sxw('report.contract.annexe.basic.report',
> + 'contract.annexe',
> + 'addons/nayar_contract_annexe_report/report/contract_annexe.rml',
> + parser=ContractAnnexeBasicReport)
>
> === added directory 'nayar_contract_annexe_report/views'
> === renamed file 'nayar_contract_annexe_report/contract_annexe_report.xml' => 'nayar_contract_annexe_report/views/contract_annexe_report.xml'
> --- nayar_contract_annexe_report/contract_annexe_report.xml 2014-06-11 10:23:47 +0000
> +++ nayar_contract_annexe_report/views/contract_annexe_report.xml 2014-07-04 10:09:26 +0000
> @@ -1,41 +1,23 @@
> <?xml version="1.0"?>
> <openerp>
> - <data>
> - <report id="contract_annexe_picking_report"
> - string="Anexo de contrato"
> - model="stock.picking"
> - name="contract.annexe.picking.report"
> - rml="nayar_contract_annexe_report/report/contract_annexe.rml"
> - groups="base.group_sale_manager"
> - header="False"
> - auto="False" />
> -
> - <report id="contract_annexe_invoice_report"
> - string="Anexo de contrato"
> - model="account.invoice"
> - name="contract.annexe.invoice.report"
> - rml="nayar_contract_annexe_report/report/contract_annexe.rml"
> - groups="base.group_sale_manager"
> - header="False"
> - auto="False" />
> -
> - <report id="contract_annexe_invoice_cp_report"
> - string="Anexos de particulares"
> - model="account.invoice"
> - name="contract.annexe.invoice.cp.report"
> - rml="nayar_contract_annexe_report/report/contract_annexe.rml"
> - groups="base.group_sale_manager"
> - header="False"
> - auto="False" />
> - <report id="contract_annexe_basic_report"
> - string="Anexo"
> - model="contract.annexe"
> - name="contract.annexe.basic.report"
> - rml="nayar_contract_annexe_report/report/contract_annexe.rml"
> - groups="base.group_sale_manager"
> - header="False"
> - auto="False" />
> -
> -
> - </data>
> + <data>
> + <report id="contract_annexe_picking_report" string="Anexo de contrato"
> + model="stock.picking" name="contract.annexe.picking.report"
> + rml="nayar_contract_annexe_report/report/contract_annexe.rml"
> + groups="base.group_sale_manager" header="False" auto="False" />
> +
> + <report id="contract_annexe_invoice_report" string="Anexo de contrato"
> + model="account.invoice" name="contract.annexe.invoice.report"
> + rml="nayar_contract_annexe_report/report/contract_annexe.rml"
> + groups="base.group_sale_manager" header="False" auto="False" />
> +
> + <report id="contract_annexe_invoice_cp_report" string="Anexos de particulares"
> + model="account.invoice" name="contract.annexe.invoice.cp.report"
> + rml="nayar_contract_annexe_report/report/contract_annexe.rml"
> + groups="base.group_sale_manager" header="False" auto="False" />
> + <report id="contract_annexe_basic_report" string="Anexo"
> + model="contract.annexe" name="contract.annexe.basic.report"
> + rml="nayar_contract_annexe_report/report/contract_annexe.rml"
> + groups="base.group_sale_manager" header="False" auto="False" />
> + </data>
> </openerp>
>
--
https://code.launchpad.net/~oihanecruce/avanzosc/nayar_contract_annexe_report/+merge/225629
Your team Avanzosc_security is subscribed to branch lp:~avanzosc-security-team/avanzosc/72horas.
References