Advertisement
Guest User

test

a guest
Mar 20th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1.     @api.model
  2.     def get_freight_matrix_supplier_ids(self):
  3.         freight_matrix_ids = supplier_ids = []
  4.  
  5.         active_model = self.env.context.get('active_model')
  6.         active_ids = self.env.context.get('active_ids', [])
  7.  
  8.         if active_model == 'jiti.freight.matrix':
  9.             freight_matrix_ids = self.env['jiti.freight.matrix'].browse(active_ids)
  10.  
  11.         else:
  12.             supplier_ids = self.env['res.partner'].browse(active_ids)
  13.             for supplier_id in supplier_ids:
  14.                 if not supplier_id.supplier:
  15.                     raise ValidationError(_('The carrier \'{}\' should be a supplier.').format(supplier_id.name))
  16.                 if not supplier_id.provides_landed_cost:
  17.                     raise ValidationError(
  18.                         _('The carrier \'{}\' should be defined as provides landed cost.'.format(supplier_id.name)))
  19.                 freight_matrix_ids = self.env['jiti.freight.matrix'].search([('carrier_id', '=', supplier_id.id)])
  20.         return freight_matrix_ids, supplier_ids
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement