コード例 #1
0
 def onchange_vehicle_id(self):
     """
     Check the vehicles available for the carrier selected and return
     a exception if the same is not available in that zone
     :return: a empty dictionary if process is ok and warning if have a
     exception
     """
     res = {}
     if not self.vehicle_id or not self.carrier_id:
         return res
     if self.carrier_id:
         veh_carrier = self.env['delivery.carrier.cost'].search(
             [('delivery_carrier_id', '=', self.carrier_id.id)], limit=10)
         veh_ids = []
         for veh in veh_carrier:
             veh_ids.append(veh.vehicle.id)
         if self.vehicle_id.id not in veh_ids:
             self.vehicle_id = self.vehicle_id.id
             res['warning'] = {
                 'title':
                 _('Warning'),
                 'message':
                 _('Selected vehicle is not available for the shipping '
                   'area. please select another vehicle.')
             }
             self.vehicle_id = self.vehicle_id.id
         else:
             return res
     return res
コード例 #2
0
 def button_validate(self):
     result = super(StockPicking, self).button_validate()
     # ~ Change the product state when is moved to other location.
     for picking in self:
         for move in picking.move_lines:
             if move.product_id.rental:
                 move.product_id.write({
                     'state_id':
                     move.location_dest_id.product_state.id,
                     'color':
                     move.location_dest_id.color,
                     'location_id':
                     move.location_dest_id.id
                 })
                 move.product_id.product_tmpl_id.write({
                     'state_id':
                     move.location_dest_id.product_state.id,
                     'color':
                     move.location_dest_id.color,
                     'location_id':
                     move.location_dest_id.id
                 })
             if move.sale_line_id.add_operator and not move.employee_id \
                and move.picking_id.location_dest_id.usage \
                == 'customer':
                 raise UserError(
                     _('You need specify a operator for: %s') %
                     move.sale_line_id.product_id.name)
             if move.product_id.product_tmpl_id.type == 'product' \
              and not move.product_id.product_tmpl_id.non_mech and \
               picking.location_id.usage == 'customer':
                 picking.generate_repair_requests()
     return result
コード例 #3
0
 def create(self, vals):
     if vals.get('partner_id'):
         partner = self.env['res.partner'].search([
             ('id', '=', vals.get('partner_id'))
         ])
         if partner.picking_warn == 'block':
             raise UserError(_(partner.picking_warn_msg))
     res = super(StockPicking, self).create(vals)
     return res
コード例 #4
0
 def cancel(self, public_crt, private_key, identifier, motive):
     client = self._get_client(public_crt, private_key)
     response = client.service.anularFactura(identifier, motive)
     if response.resultado.codigo != "0":
         raise UserError(
             _("Connection with FACe returned error %s - %s")
             % (response.resultado.codigo, response.resultado.descripcion)
         )
     return response
コード例 #5
0
ファイル: stock_move.py プロジェクト: mah007/conalquipo
 def _action_done(self, merge=True):
     res = super(StockMove, self)._action_done()
     # This block create a history entry
     history = self.env['stock.move.history']
     for order in res:
         if order.picking_id.picking_type_id.code != 'internal':
             date = order.picking_id.advertisement_date \
                 or order.date_expected
             m_histories = history.search([
                 ('partner_id', '=', order.picking_id.partner_id.id),
                 ('project_id', '=', order.picking_id.project_id.id),
                 ('product_id', '=', order.product_id.id),
                 ('date', '>=', date),
             ])
             m_histories = m_histories.filtered(
                 lambda h: h.invoice_line_ids and h.invoice_line_ids.
                 filtered(lambda b: b.invoice_id.state != 'cancel'))
             if m_histories:
                 raise UserError(
                     _('The move of the product %s, can not be generated '
                       'for this period, since it is in the following '
                       'invoices: %s') %
                     (order.product_id.name, ', '.join(
                         list(
                             set([
                                 li.invoice_id.name or li.invoice_id.origin
                                 for li in m_histories.mapped(
                                     'invoice_line_ids')
                             ])))))  # noqa
             vals = {
                 'picking_id': order.picking_id.id,
                 'partner_id': order.picking_id.partner_id.id,
                 'project_id': order.picking_id.project_id.id,
                 'product_id': order.product_id.id,
                 'code': order.picking_id.picking_type_id.code,
                 'product_count': order.product_count,
                 'quantity_done': order.quantity_done,
                 'sale_line_id': order.sale_line_id.id,
                 'move_id': order.id,
             }
             _logger.info(
                 "Creating history entry on table stock.move.history")
             history.create(vals)
             _logger.info("History entry creation successful")
     # end of history entry
     for order in self:
         if order.state == 'done' and order.returned:
             move = order.env['stock.move'].search(
                 [('id', '=', order.returned)], limit=1)
             if move:
                 move.write({'origin_returned_move_id': order.id})
     return res
コード例 #6
0
 def onchange_employe_code(self):
     if self.employee_code:
         employee_list = []
         actual_user = self.env.user
         other = actual_user.employee_ids
         for data in other:
             employee_list.append(data.id)
         code = self.env['hr.employee'].search(
             [('employee_code', '=', self.employee_code)], limit=1)
         if code.id in employee_list:
             self.employee_id = code.id
         else:
             raise UserError(
                 _('This employee code in not member of '
                   'this group.'))
     else:
         self.employee_id = False
コード例 #7
0
 def write(self, values):
     # Overwrite stock picking write
     values['employee_code'] = False
     res = super(StockPicking, self).write(values)
     for pk in self:
         carrier = pk.carrier_id
         vehicle = pk.vehicle_id
         if pk.carrier_type == 'company':
             for data in pk.delivery_cost:
                 if data.vehicle_id.id != pk.vehicle_id.id:
                     raise UserError(
                         _("""
                         This vehicle or carrier doesn't match.
                         Please, contact with a commercial to create a new
                             line in the order with the correct carrier
                             and vehicle for this picking.
                         """))
     return res
コード例 #8
0
 def button_scrap(self):
     self.ensure_one()
     products = self.env['product.product']
     for move in self.move_lines:
         if move.state not in ('done') and \
          move.product_id.type in ('product', 'consu'):
             products |= move.product_id
     return {
         'name': _('Scrap'),
         'view_type': 'form',
         'view_mode': 'form',
         'res_model': 'stock.scrap',
         'view_id': self.env.ref('stock.stock_scrap_form_view2').id,
         'type': 'ir.actions.act_window',
         'context': {
             'default_picking_id': self.id,
             'product_ids': products.ids
         },
         'target': 'new',
     }
コード例 #9
0
ファイル: web.py プロジェクト: PrakashThapa/dockerodoo
 def report_routes(self, reportname, docids=None, converter=None, **data):
     if converter == "reportlab-pdf":
         report_slip = request.env.ref(
             'l10n_ch_payment_slip.one_slip_per_page_from_invoice')
         filename = ''
         invoice_id = []
         if docids:
             invoice_id = [int(i) for i in docids.split(',')]
             filename = ''.join([
                 _('ISR'), '_multiple_invoices' if len(invoice_id) > 1 else
                 '{0:05d}'.format(invoice_id[0]), '.pdf'
             ])
         data, format_report = report_slip.render(invoice_id)
         pdfhttpheaders = [
             ('Content-Type', 'application/pdf'),
             ('Content-Disposition', content_disposition(filename)),
             ('Content-Length', len(data)),
         ]
         return request.make_response(data, headers=pdfhttpheaders)
     return super(ReportController,
                  self).report_routes(reportname, docids, converter, **data)