← Back to team overview

avanzosc team mailing list archive

Re: [Merge] lp:~mikelarregi/avanzosc/dos_stock_picking_report into lp:~avanzosc-security-team/avanzosc/72horas

 

Review: Approve code review

Sólo un pequeño comentario no bloqueante.

Diff comments:

> === modified file 'dos_stock_picking_report/__init__.py'
> --- dos_stock_picking_report/__init__.py	2014-06-11 10:23:47 +0000
> +++ dos_stock_picking_report/__init__.py	2014-07-02 15:00:10 +0000
> @@ -18,7 +18,6 @@
>  #
>  ##############################################################################
>  
> -import report
> +from . import report
>  
>  # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
> -
> 
> === modified file 'dos_stock_picking_report/__openerp__.py'
> --- dos_stock_picking_report/__openerp__.py	2014-06-11 10:23:47 +0000
> +++ dos_stock_picking_report/__openerp__.py	2014-07-02 15:00:10 +0000
> @@ -19,20 +19,19 @@
>  ##############################################################################
>  
>  {
> -	"name" : "DOS Stock Picking Report",
> -	"version" : "1.0",
> -	"author" : "DOS",
> -	"category" : "Enterprise Specific Modules",
> -	"description":"""Module to print stock pickings with custom format.
> -	""",
> -	"depends" : ["stock"],
> -	"init_xml" : [],
> -	"demo_xml" : [],
> -	"update_xml" : [
> -		'stock_picking_report.xml',
> -	],
> -	"website": 'http://www.dos-sl.es',
> -	"active": False,
> -	"installable": True,
> +    "name" : "DOS Stock Picking Report",
> +    "version" : "1.0",
> +    "author" : "DOS",
> +    "category" : "Enterprise Specific Modules",
> +    "description":"""Module to print stock pickings with custom format.
> +    """,
> +    "depends" : ["stock"],
> +    "init_xml" : [],

Quitar init_xml y demo_xml

> +    "demo_xml" : [],
> +    "data" : [
> +        'views/stock_picking_report.xml',
> +    ],
> +    "website": 'http://www.dos-sl.es',
> +    "installable": True,
>  }
>  # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
> 
> === modified file 'dos_stock_picking_report/report/__init__.py'
> --- dos_stock_picking_report/report/__init__.py	2014-06-11 10:23:47 +0000
> +++ dos_stock_picking_report/report/__init__.py	2014-07-02 15:00:10 +0000
> @@ -21,4 +21,3 @@
>  import stock_picking
>  
>  # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
> -
> 
> === modified file 'dos_stock_picking_report/report/stock_picking.py'
> --- dos_stock_picking_report/report/stock_picking.py	2014-06-11 10:23:47 +0000
> +++ dos_stock_picking_report/report/stock_picking.py	2014-07-02 15:00:10 +0000
> @@ -21,14 +21,15 @@
>  
>  import time
>  from datetime import datetime
> -from report import report_sxw
> -from osv import osv
> -from tools.translate import _
> -import pooler
> -
> -class stock_picking_custom(report_sxw.rml_parse):
> +from openerp.report import report_sxw
> +from openerp.osv import orm, fields
> +from openerp.tools.translate import _
> +
> +
> +class StockPickingCustom(report_sxw.rml_parse):
>      def __init__(self, cr, uid, name, context):
> -        super(stock_picking_custom, self).__init__(cr, uid, name, context=context)
> +        super(StockPickingCustom, self).__init__(cr, uid, name,
> +                                                 context=context)
>          self.localcontext.update({
>              'time': time,
>              'get_left_text': self.get_left_text,
> @@ -43,298 +44,272 @@
>              'get_annexe_lines': self.get_annexe_lines,
>          })
>          self.context = context
> -        user = self.pool.get('res.users').browse(cr, uid, uid)
> +        user = self.pool['res.users'].browse(cr, uid, uid, context=context)
>          self.company = user.company_id
> -		
> -        
> -    def get_stock_date (self, picking):
> +
> +    def get_stock_date(self, picking):
>          picking_date = ""
> -        
>          if picking.date:
>              picking_date = datetime.strptime(picking.date[0:10], '%Y-%m-%d')
>              picking_date = picking_date.strftime('%d/%m/%Y')
> -            
>          return picking_date
> -    
> -    def get_format_stock_date (self, picking):
> +
> +    def get_format_stock_date(self, picking):
>          format_date = ""
> -        
>          if picking.date:
>              picking_date = datetime.strptime(picking.date[0:10], '%Y-%m-%d')
> -            format_date =  str(picking_date.day) + ' de ' +  picking_date.strftime('%B').capitalize() + ' de ' + str(picking_date.year)
> -            
> +            format_date = (
> +                '%s de %s de %s' % (str(picking_date.day),
> +                                    picking_date.strftime('%B').capitalize(),
> +                                    str(picking_date.year)))
>          return format_date
> -    
> -    def get_num_annexe_ship (self, picking):
> +
> +    def get_num_annexe_ship(self, picking):
>          num_annexe_ship = ""
> -        
>          for m in picking.move_lines:
>              if m.contract_annexe_id and m.contract_annexe_id.num_annexe_ship:
>                  num_annexe_ship = m.contract_annexe_id.num_annexe_ship
>                  break
> -            
>          return num_annexe_ship
> -    
> -    
> +
>      def get_left_text(self, picking):
> -        
>          text = ""
> -        
>          company = picking.company_id or self.company or None
> -        
>          if company and company.partner_id:
> -            
>              partner = company.partner_id
> -
>              # 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 (" - %s %s " % (_("RM Tomo"),
> +                                                        partner.es_tomo)) or ""
>              # Libro
> -            text += partner.es_libro and (" " + _("Libro") + " " + partner.es_libro) or ""
> +            text += partner.es_libro and (" %s %s " % (_("Libro"),
> +                                                       partner.es_libro)) or ""
>              # Folio
> -            text += partner.es_folio and (" " + _("Folio") + " " + partner.es_folio) or ""    
> +            text += partner.es_folio and (" %s %s " % (_("Folio"),
> +                                                       partner.es_folio)) or ""
>              # Hoja
> -            text += partner.es_hoja and (" " + _("Hoja") + " " + partner.es_hoja) or ""    
> +            text += partner.es_hoja and (" %s %s " % (_("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
> +                (" %s %s " % (_("Inscripción"),
> +                              partner.es_registro_mercantil)) or "")
>              # Final
> -            text += "."        
> +            text += "."
> +        return text
>  
> -        return text
> -    
>      def get_footer_text(self, picking):
> -        
>          text = ""
> -        
>          company = picking.company_id or self.company or None
> -        
>          if company and company.partner_id:
> -            
>              partner = company.partner_id
> -            addr_ids = self.pool.get('res.partner').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)
> -            
>              # Nombre empresa
>              text += partner and partner.name or ""
>              # Calle empresa
> -            text += addr and addr.street and (" - " + addr.street + ".") or ""
> +            text += partner.street and (" - " + partner.street + ".") or ""
>              # Codigo Postal empresa
> -            text += addr and addr.zip and (" - " + addr.zip) or ""
> +            text += partner.zip and (" - " + partner.zip) or ""
>              # Ciudad
> -            text += addr and addr.city and (" " + addr.city) or ""
> +            text += partner.city and (" " + partner.city) or ""
>              # Telefono
> -            text += addr and addr.phone and (" - " + _("Tel.") + " " + addr.phone) or ""
> +            text += partner.phone and (" - %s %s" %
> +                                       (_("Tel."), partner.phone)) or ""
>              # Fax
> -            text += addr and addr.fax and (" - " + _("Fax.") + " " + addr.fax) or ""
> +            text += partner.fax and (" - %s %s" %
> +                                     (_("Fax."), partner.fax)) or ""
>              # Email
> -            text += addr and addr.email and (" - " + _("E-Mail") + " " + addr.email) or ""
> -            
> +            text += partner.email and (" - %s %s" %
> +                                       (_("E-Mail"), partner.email)) or ""
>          return text
> -         
> -    def get_company_address (self, picking):
> -        
> +
> +    def get_company_address(self, picking):
>          res = []
> -        
>          company = picking.company_id or self.company or None
> -        
>          if company and company.partner_id:
> -            
>              partner = company.partner_id
> -            addr_ids = self.pool.get('res.partner').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)
> -            
> -            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(partner.name or "")
> +            res.append((partner.street) or '')
> +            res.append((partner.zip or '') + " - " + (partner.city or ''))
> +            res.append("%s (%s)" %
> +                       ((partner.state_id and partner.state_id.name or ''),
> +                        (partner.country_id and partner.country_id.name or ''))
> +                       )
>              res.append(partner and partner.vat or '')
> -            
>          else:
> -            
> -            res.append(" ")
> -            res.append(" ")
> -            res.append(" ")
> -            res.append(" ")
> -            res.append(" ")
> -            
> +            for i in range(5):
> +                res.append(" ")
>              """
>              res.append("Nayar Systems S.L.")
>              res.append("Calle Taxida 10")
>              res.append("12003 Castellón")
>              res.append("España")
> -            res.append("B-12757795") 
> +            res.append("B-12757795")
>              """
> -            
>          return res
>  
> -    def get_customer_address (self, picking):
> -
> +    def get_customer_address(self, picking):
>          res = []
> -
>          if picking.partner_id:
> -
>              partner = picking.partner_id
> -            addr_ids = self.pool.get('res.partner').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)
> -
>              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((partner.street) or '')
> +            res.append("%s - %s" % ((partner.zip or ''),
> +                                    (partner.city or '')))
> +            res.append("%s (%s)" %
> +                       ((partner.state_id and partner.state_id.name or ''),
> +                        (partner.country_id and partner.country_id.name or ''))
> +                       )
>              res.append(partner and partner.vat or '')
> -
>          else:
> -
> -            res.append(" ")
> -            res.append(" ")
> -            res.append(" ")
> -            res.append(" ")
> -            res.append(" ")
> +            for i in range(5):
> +                res.append(" ")
>  
>          return res
>  
> -    def get_delivery_address (self, picking):
> -        
> +    def get_delivery_address(self, picking):
>          res = []
> -        
>          if picking.address_id:
> -            
>              partner = picking.address_id.partner_id
> -            addr = picking.address_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((partner.street) or '')
> +            res.append("%s - %s" % ((partner.zip or ''),
> +                                    (partner.city or '')))
> +            res.append("%s (%s)" %
> +                       ((partner.state_id and partner.state_id.name or ''),
> +                        (partner.country_id and partner.country_id.name or ''))
> +                       )
>              res.append(partner and partner.vat or '')
> -                     
>          else:
> -            
> -            res.append(" ")
> -            res.append(" ")
> -            res.append(" ")
> -            res.append(" ")
> -            res.append(" ")
> +            for i in range(5):
> +                res.append(" ")
> +        return res
>  
> -        return res
> -         
> -    def get_num_order(self, move, order_line):
> -        
> -        product_obj = self.pool.get('product.product')
> -        annexe_obj = self.pool.get('contract.annexe')
> -        
> +    def get_num_order(self, move, order_line, context=None):
> +        product_obj = self.pool['product.product']
> +        annexe_obj = self.pool['contract.annexe']
>          annexe_id = None
>          annexe_ids = None
> -        
>          if move.contract_annexe_id:
>              annexe_id = move.contract_annexe_id
>          else:
>              if product_obj._is_sim(move.product_id.categ_id):
> -                annexe_ids = annexe_obj.search(self.cr, self.uid, [("product_id", "=", move.product_id.id), ("production_lot_id", "=", move.prodlot_id.id), ("active_annexe", "=", True)])
> +                annexe_ids = (
> +                    annexe_obj.search(
> +                        self.cr, self.uid,
> +                        [("product_id", "=", move.product_id.id),
> +                         ("production_lot_id", "=", move.prodlot_id.id),
> +                         ("active_annexe", "=", True)], context=context))
>              elif product_obj._is_link(move.product_id.categ_id):
> -                annexe_ids = annexe_obj.search(self.cr, self.uid, [("product_2_id", "=", move.product_id.id), ("production_lot_2_id", "=", move.prodlot_id.id), ("active_annexe", "=", True)])
> +                annexe_ids = annexe_obj.search(
> +                    self.cr, self.uid,
> +                    [("product_2_id", "=", move.product_id.id),
> +                     ("production_lot_2_id", "=", move.prodlot_id.id),
> +                     ("active_annexe", "=", True)], context=context)
>              elif product_obj._is_pack(move.product_id.categ_id):
> -                annexe_ids = annexe_obj.search(self.cr, self.uid, [("pack_product_id", "=", move.product_id.id), ("pack_production_lot_id", "=", move.prodlot_id.id), ("active_annexe", "=", True)])                   
> -            
> -            annexe_id = annexe_ids and annexe_obj.browse(self.cr, self.uid, annexe_ids[0]) or None
> -            
> -        return (annexe_id and annexe_id.customer_ref) or (order_line and order_line.client_order_ref) or (order_line and order_line.order_id and order_line.order_id.client_order_ref) or ""
> -                 
> -    def get_move_lines (self, picking):
> -        
> -        product_obj = self.pool.get('product.product')
> -        
> +                annexe_ids = annexe_obj.search(
> +                    self.cr, self.uid,
> +                    [("pack_product_id", "=", move.product_id.id),
> +                     ("pack_production_lot_id", "=", move.prodlot_id.id),
> +                     ("active_annexe", "=", True)], context=context)
> +            annexe_id = annexe_ids and annexe_obj.browse(
> +                self.cr, self.uid, annexe_ids[0], context=context) or None
> +        return (
> +            (annexe_id and annexe_id.customer_ref) or
> +            (order_line and order_line.client_order_ref) or
> +            (order_line and order_line.order_id and
> +             order_line.order_id.client_order_ref) or "")
> +
> +    def get_move_lines(self, picking, context=None):
> +        product_obj = self.pool['product.product']
>          res = []
> -        
>          lines = []
>          links = []
>          others = []
> -
>          for m in picking.move_lines:
>              move = {}
> -
>              order_line = None
> -            annexe_obj = self.pool.get('contract.annexe')
> -            
> +            annexe_obj = self.pool['contract.annexe']
>              if m.sale_line_id:
>                  order_line = m.sale_line_id
>              elif m.purchase_line_id:
>                  order_line = m.purchase_line_id
> -                
>              concept = m.product_id and m.product_id.name or " "
>              uds = int(m.product_qty or 0)
> -            num_order = self.get_num_order(m, order_line)
> -
> +            num_order = self.get_num_order(m, order_line, context=context)
>              move["concept"] = concept
>              move["num_order"] = num_order
>              move["uds"] = uds
>              move["price"] = order_line and order_line.price_unit or 0
>              move["dto"] = order_line and order_line.discount
> -            
> -            if m.product_id and (product_obj._is_sim(m.product_id.categ_id) or product_obj._is_pack(m.product_id.categ_id)):
> -                move['concept'] = _("Línea Móvil ") + (m.prodlot_id and m.prodlot_id.telefono or " ")
> -		if picking.partner_id.tipo_albaran == 'valorado':
> -		    move['concept'] += _(" (precio mensual)")
> +            if (m.product_id and
> +                    (product_obj._is_sim(m.product_id.categ_id) or
> +                     product_obj._is_pack(m.product_id.categ_id))):
> +                move['concept'] = (
> +                    _("Línea Móvil ") +
> +                    (m.prodlot_id and m.prodlot_id.telefono or " "))
> +                if picking.partner_id.tipo_albaran == 'valorado':
> +                    move['concept'] += _(" (precio mensual)")
>                  move['uds'] = " "
>                  move["type"] = "sim"
> -
>                  if move["price"] == 0:
> -                    annexe_id = annexe_obj.search(self.cr, self.uid, [('production_lot_id', '=', m.prodlot_id.id)])
> +                    annexe_id = annexe_obj.search(
> +                        self.cr, self.uid, [('production_lot_id', '=',
> +                                             m.prodlot_id.id)], context=context
> +                        )
>                      if annexe_id:
> -                        annexe = annexe_obj.browse(self.cr, self.uid, annexe_id[0])
> +                        annexe = annexe_obj.browse(
> +                            self.cr, self.uid, annexe_id[0], context=context)
>                          move["price"] = annexe['fixed_price']
>                          move['dto'] = annexe['differential_price']
>                  lines.append(move.copy())
> -
> -            elif (m.product_id and product_obj._is_link(m.product_id.categ_id) or m.product_id and product_obj._is_pack(m.product_id.categ_id)):
> -                move['concept'] = (m.product_id and m.product_id.name or "") + _(" Imei ") + (m.prodlot_id and m.prodlot_id.imei or " ")
> +            elif (m.product_id and product_obj._is_link(m.product_id.categ_id)
> +                    or m.product_id and
> +                    product_obj._is_pack(m.product_id.categ_id)):
> +                move['concept'] = ("%s%s%s" %
> +                                   ((m.product_id and m.product_id.name or ""),
> +                                    _(" Imei "), (m.prodlot_id and
> +                                                  m.prodlot_id.imei or " ")))
>                  move['uds'] = uds
>                  move["type"] = "track"
>                  links.append(move.copy())
> -
> -            elif m.product_id and product_obj._is_shipping_cost(m.product_id.categ_id):
> +            elif (m.product_id and
> +                  product_obj._is_shipping_cost(m.product_id.categ_id)):
>                  if picking.partner_id.tipo_albaran == 'valorado':
>                      move["type"] = "other"
>                      others.append(move.copy())
> -
>              else:
>                  move["type"] = "other"
>                  others.append(move.copy())
> -
>          res = lines + links + others
> -                
>          return res
> -    
> -   
> -    def get_annexe_lines (self, picking):
>  
> -        annexe_obj = self.pool.get('contract.annexe')
> -        
> +    def get_annexe_lines(self, picking):
> +        annexe_obj = self.pool['contract.annexe']
>          res = []
> -        
>          annexe_ids = []
>          for m in picking.move_lines:
> -            if m.contract_annexe_id and not (m.contract_annexe_id.id in annexe_ids):
> +            if (m.contract_annexe_id and
> +                    not (m.contract_annexe_id.id in annexe_ids)):
>                  annexe_ids.append(m.contract_annexe_id.id)
> -            
>          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
>  
> -		
> -report_sxw.report_sxw('report.stock.picking.custom','stock.picking','addons/dos_stock_picking_report/report/stock_picking.rml',parser=stock_picking_custom)
> +report_sxw.report_sxw('report.stock.picking.custom', 'stock.picking',
> +                      'addons/dos_stock_picking_report/report/'
> +                      'stock_picking.rml', parser=StockPickingCustom)
>  # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
> 
> === added directory 'dos_stock_picking_report/views'
> === renamed file 'dos_stock_picking_report/stock_picking_report.xml' => 'dos_stock_picking_report/views/stock_picking_report.xml'


-- 
https://code.launchpad.net/~mikelarregi/avanzosc/dos_stock_picking_report/+merge/225343
Your team Avanzosc_security is subscribed to branch lp:~avanzosc-security-team/avanzosc/72horas.


References