Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @api.model
- def get_freight_matrix_supplier_ids(self):
- freight_matrix_ids = supplier_ids = []
- active_model = self.env.context.get('active_model')
- active_ids = self.env.context.get('active_ids', [])
- if active_model == 'jiti.freight.matrix':
- freight_matrix_ids = self.env['jiti.freight.matrix'].browse(active_ids)
- else:
- supplier_ids = self.env['res.partner'].browse(active_ids)
- for supplier_id in supplier_ids:
- if not supplier_id.supplier:
- raise ValidationError(_('The carrier \'{}\' should be a supplier.').format(supplier_id.name))
- if not supplier_id.provides_landed_cost:
- raise ValidationError(
- _('The carrier \'{}\' should be defined as provides landed cost.'.format(supplier_id.name)))
- freight_matrix_ids = self.env['jiti.freight.matrix'].search([('carrier_id', '=', supplier_id.id)])
- return freight_matrix_ids, supplier_ids
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement