mirror of
https://github.com/NaN-tic/trytond-carrier_zip.git
synced 2023-12-14 02:13:03 +01:00
Added method get_carriers_from_zip to Carrier model
This commit is contained in:
parent
9d14e138c5
commit
a29d955689
1 changed files with 10 additions and 1 deletions
11
carrier.py
11
carrier.py
|
@ -2,7 +2,7 @@
|
||||||
# The COPYRIGHT file at the top level of this repository contains the full
|
# The COPYRIGHT file at the top level of this repository contains the full
|
||||||
# copyright notices and license terms.
|
# copyright notices and license terms.
|
||||||
from trytond.model import ModelView, ModelSQL, fields
|
from trytond.model import ModelView, ModelSQL, fields
|
||||||
from trytond.pool import PoolMeta
|
from trytond.pool import Pool, PoolMeta
|
||||||
|
|
||||||
__metaclass__ = PoolMeta
|
__metaclass__ = PoolMeta
|
||||||
__all__ = ['CarrierZip', 'Carrier']
|
__all__ = ['CarrierZip', 'Carrier']
|
||||||
|
@ -40,3 +40,12 @@ class CarrierZip(ModelSQL, ModelView):
|
||||||
class Carrier:
|
class Carrier:
|
||||||
__name__ = 'carrier'
|
__name__ = 'carrier'
|
||||||
zips = fields.One2Many('carrier.zip', 'carrier', 'Carrier Zips')
|
zips = fields.One2Many('carrier.zip', 'carrier', 'Carrier Zips')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_carriers_from_zip(zip_code):
|
||||||
|
CarrierZip = Pool().get('carrier.zip')
|
||||||
|
carrier_zips = CarrierZip.search([
|
||||||
|
('start_zip', '<=', zip_code),
|
||||||
|
('end_zip', '>=', zip_code),
|
||||||
|
])
|
||||||
|
return [c.carrier for c in carrier_zips]
|
||||||
|
|
Loading…
Reference in a new issue