first commit

This commit is contained in:
root
2026-03-14 09:42:12 +00:00
commit 0adbd20c2c
10991 changed files with 1646955 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.

View File

@@ -0,0 +1,81 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import re
from trytond.model import fields
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval
class Selection(metaclass=PoolMeta):
__name__ = 'carrier.selection'
from_subdivision = fields.Many2One(
'country.subdivision', "From Subdivision", ondelete='RESTRICT',
domain=[
('country', '=', Eval('from_country', -1)),
],
states={
'invisible': ~Eval('from_country'),
},
help="The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision.")
from_postal_code = fields.Char("From Postal Code",
help=""
"The regular expression to match the postal codes "
"the carrier collects from.\n"
"Leave empty to allow collection from any postal code.")
to_subdivision = fields.Many2One(
'country.subdivision', "To Subdivision", ondelete='RESTRICT',
domain=[
('country', '=', Eval('to_country', -1)),
],
states={
'invisible': ~Eval('to_country'),
},
help="The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision.")
to_postal_code = fields.Char("To Postal Code",
help=""
"The regular expression to match the postal codes "
"the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code.")
def match(self, pattern, match_none=False):
pool = Pool()
Subdivision = pool.get('country.subdivision')
def parents(subdivision):
if subdivision is None:
return []
subdivision = Subdivision(subdivision)
while subdivision:
yield subdivision
subdivision = subdivision.parent
if 'from_subdivision' in pattern:
pattern = pattern.copy()
from_subdivision = pattern.pop('from_subdivision')
if (self.from_subdivision is not None
and self.from_subdivision not in parents(
from_subdivision)):
return False
if 'from_postal_code' in pattern:
pattern = pattern.copy()
from_postal_code = pattern.pop('from_postal_code') or ''
if (self.from_postal_code is not None
and not re.match(self.from_postal_code, from_postal_code)):
return False
if 'to_subdivision' in pattern:
pattern = pattern.copy()
to_subdivision = pattern.pop('to_subdivision')
if (self.to_subdivision is not None
and self.to_subdivision not in parents(to_subdivision)):
return False
if 'to_postal_code' in pattern:
pattern = pattern.copy()
to_postal_code = pattern.pop('to_postal_code') or ''
if (self.to_postal_code is not None
and not re.search(self.to_postal_code, to_postal_code)):
return False
return super().match(pattern, match_none=match_none)

View File

@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="ir.ui.view" id="carrier_selection_view_form">
<field name="model">carrier.selection</field>
<field name="inherit" ref="carrier.carrier_selection_view_form"/>
<field name="name">carrier_selection_form</field>
</record>
<record model="ir.ui.view" id="carrier_selection_view_list">
<field name="model">carrier.selection</field>
<field name="inherit" ref="carrier.carrier_selection_view_list"/>
<field name="name">carrier_selection_list</field>
</record>
<record model="ir.ui.view" id="carrier_selection_view_list_sequence">
<field name="model">carrier.selection</field>
<field name="inherit" ref="carrier.carrier_selection_view_list_sequence"/>
<field name="name">carrier_selection_list</field>
</record>
</data>
</tryton>

View File

@@ -0,0 +1,43 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr ""
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr ""
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr ""
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr ""
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""

View File

@@ -0,0 +1,51 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr "Del codi postal"
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr "De la subdivisió"
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr "Al codi postal"
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr "A la subdiviisió"
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
"Expressió regular que coincideix amb els codis postals dels quals recull el transportista.\n"
"Deixeu-ho en blanc per permetre la recollida de qualsevol codi postal."
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
"La subdivisió de la qual recull el transportista.\n"
"Deixeu-ho en blanc per permetre la recollida de qualsevol subdivisió."
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
"Expressió regular que coincideix amb els codis postals als quals entrega el transportista.\n"
"Deixeu-ho en blanc per permetre l'entrega a qualsevol codi postal."
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""
"La subdivisió a la qual el transportista entrega.\n"
"Deixar buida per permetre l'entrega a qualsevol subdivisió."

View File

@@ -0,0 +1,43 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr ""
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr ""
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr ""
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr ""
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""

View File

@@ -0,0 +1,51 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr "Ursprungsland Postleitzahl"
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr "Ursprungslandsregion"
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr "Bestimmungsland Postleitzahl"
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr "Bestimmungslandsregion"
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
"Der reguläre Ausdruck um die Postleitzahlen zuzuordnen von denen der Versanddienstleister abhholt.\n"
"Leer lassen um Abholung von allen Postleitzahlen zuzulassen."
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
"Von dieser Region holt der Versanddienstleister ab.\n"
"Leer lassen, um die Abholung von allen Regionen zuzulassen."
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
"Der reguläre Ausdruck um die Postleitzahlen zuzuordnen an die der Versanddienstleister liefert.\n"
"Leer lassen um die Lieferung an alle Postleitzahlen zuzulassen."
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""
"Die Region an die der Versanddienstleister liefert.\n"
"Leer lassen um die Lieferung an alle Regionen zuzulassen."

View File

@@ -0,0 +1,51 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr "Del código postal"
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr "De la subdivisión"
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr "Al código postal"
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr "A la subdivisión"
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
"Expresión regular correspondiente a los códigos postales de los que recoge el transportista.\n"
"Dejar vacía para permitir recoger de cualquier código postal."
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
"La subdivisión de la que recoge el transportista.\n"
"Dejar vacía para permitir recoger de cualquier subdivisión."
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
"Expresión regular correspondiente a los códigos postales a los que entrega el transportista.\n"
"Dejar vacía para permitir entregar a cualquier código postal."
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""
"La subdivisión a la cual el transportista entrega.\n"
"Dejar vacía para permitir envíos a cualquier subdivisión."

View File

@@ -0,0 +1,43 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr ""
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr ""
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr ""
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr ""
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""

View File

@@ -0,0 +1,43 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr ""
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr ""
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr ""
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr ""
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""

View File

@@ -0,0 +1,43 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr ""
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr ""
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr ""
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr ""
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""

View File

@@ -0,0 +1,43 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr ""
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr ""
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr ""
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr ""
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""

View File

@@ -0,0 +1,51 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr "Du code postal"
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr "De la subdivision"
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr "Vers le code postal"
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr "Vers la subdivision"
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
"Expression régulière correspondant aux codes postaux desquelles le transporteur collecte.\n"
"Laissez vide pour autoriser la collecte à partir de n'importe quel code postal."
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
"La subdivision à partir de laquelle le transporteur collecte.\n"
"Laissez vide pour autoriser la collecte à partir de n'importe quelle subdivision."
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
"L'expression régulière correspondant aux codes postaux vers lesquelles le transporteur livre.\n"
"Laissez vide pour autoriser la livraison à n'importe quel code postal."
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""
"La subdivision vers laquelle le transporteur livre.\n"
"Laissez vide pour permettre la livraison dans n'importe quelle subdivision."

View File

@@ -0,0 +1,43 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr ""
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr ""
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr ""
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr ""
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""

View File

@@ -0,0 +1,43 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr ""
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr ""
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr ""
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr ""
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""

View File

@@ -0,0 +1,51 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr "Dal codice postale"
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr "Da suddivisione"
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr "Al codice postale"
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr "Alla suddivisione"
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
"L'espressione regolare per abbinare i codici postali da cui il corriere effettua la raccolta.\n"
"Lascia vuoto per consentire il ritiro da qualsiasi codice postale."
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
"La suddivisione da cui il corriere esegue la raccolta.\n"
"Lascia vuoto per consentire il ritiro da qualsiasi suddivisione."
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
"L'espressione regolare per abbinare i codici postali dove il corriere può consegnare.\n"
"Lascia vuoto per consentire la consegna a qualsiasi codice postale."
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""
"LA suddivisione dove il corriere può consegnare.\n"
"Lascia vuoto per consentire la consegna a qualsiasi suddivisione."

View File

@@ -0,0 +1,43 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr ""
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr ""
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr ""
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr ""
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""

View File

@@ -0,0 +1,43 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr ""
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr ""
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr ""
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr ""
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""

View File

@@ -0,0 +1,51 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr "Van postcode"
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr "van subdivisie"
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr "Naar postcode"
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr "naar subdivisie"
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
"De reguliere expressie die overeenkomt met de postcodes waar de vervoerder ophaalt.\n"
"Laat leeg om collectie vanaf elke postcode toe te staan."
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
"De subdivisie waaruit de vervoerder verzamelt.\n"
"Laat leeg om inzameling vanuit elke subdivisie mogelijk te maken."
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
"De reguliere expressie die overeenkomt met de postcodes waar de transporteur bezorgt.\n"
"Laat leeg om levering op elke postcode mogelijk te maken."
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""
"De subdivisie waaraan de vervoerder levert.\n"
"Laat leeg om levering aan een onderverdeling mogelijk te maken."

View File

@@ -0,0 +1,43 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr ""
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr ""
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr ""
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr ""
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""

View File

@@ -0,0 +1,43 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr ""
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr ""
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr ""
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr ""
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""

View File

@@ -0,0 +1,43 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr ""
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr ""
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr ""
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr ""
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""

View File

@@ -0,0 +1,43 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr ""
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr ""
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr ""
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr ""
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""

View File

@@ -0,0 +1,43 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr ""
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr ""
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr ""
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr ""
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""

View File

@@ -0,0 +1,43 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr ""
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr ""
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr ""
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr ""
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""

View File

@@ -0,0 +1,43 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr ""
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr ""
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr ""
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr ""
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""

View File

@@ -0,0 +1,43 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:carrier.selection,from_postal_code:"
msgid "From Postal Code"
msgstr ""
msgctxt "field:carrier.selection,from_subdivision:"
msgid "From Subdivision"
msgstr ""
msgctxt "field:carrier.selection,to_postal_code:"
msgid "To Postal Code"
msgstr ""
msgctxt "field:carrier.selection,to_subdivision:"
msgid "To Subdivision"
msgstr ""
msgctxt "help:carrier.selection,from_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier collects from.\n"
"Leave empty to allow collection from any postal code."
msgstr ""
msgctxt "help:carrier.selection,from_subdivision:"
msgid ""
"The subdivision the carrier collects from.\n"
"Leave empty to allow collection from any subdivision."
msgstr ""
msgctxt "help:carrier.selection,to_postal_code:"
msgid ""
"The regular expression to match the postal codes the carrier delivers to.\n"
"Leave empty to allow delivery to any postal code."
msgstr ""
msgctxt "help:carrier.selection,to_subdivision:"
msgid ""
"The subdivision the carrier delivers to.\n"
"Leave empty to allow delivery to any subdivision."
msgstr ""

View File

@@ -0,0 +1,49 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.model import fields
from trytond.pool import PoolMeta
class Sale(metaclass=PoolMeta):
__name__ = 'sale.sale'
@fields.depends('warehouse', 'shipment_address')
def _get_carrier_selection_pattern(self):
pattern = super()._get_carrier_selection_pattern()
pattern['from_subdivision'] = None
if self.warehouse and self.warehouse.address:
address = self.warehouse.address
if address.subdivision:
pattern['from_subdivision'] = address.subdivision.id
if address.postal_code:
pattern['from_postal_code'] = address.postal_code
pattern['to_subdivision'] = None
if self.shipment_address:
address = self.shipment_address
if address.subdivision:
pattern['to_subdivision'] = address.subdivision.id
if address.postal_code:
pattern['to_postal_code'] = address.postal_code
return pattern
class Carriage(metaclass=PoolMeta):
__name__ = 'sale.carriage'
@fields.depends('from_', 'to')
def _get_carrier_selection_pattern(self):
pattern = super()._get_carrier_selection_pattern()
pattern['from_subdivision'] = None
if self.from_:
if self.from_.subdivision:
pattern['from_subdivision'] = self.from_.subdivision.id
if self.from_.postal_code:
pattern['from_postal_code'] = self.from_.postal_code
pattern['to_subdivision'] = None
if self.to:
if self.to.subdivision:
pattern['to_subdivision'] = self.to.subdivision.id
if self.to.postal_code:
pattern['to_postal_code'] = self.to.postal_code
return pattern

View File

@@ -0,0 +1,2 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.

View File

@@ -0,0 +1,121 @@
============================
Carrier Subdivision Scenario
============================
Imports::
>>> from decimal import Decimal
>>> from proteus import Model
>>> from trytond.modules.company.tests.tools import create_company
>>> from trytond.tests.tools import activate_modules, assertEqual
Activate modules::
>>> config = activate_modules(
... ['carrier_subdivision', 'sale_shipment_cost'], create_company)
Create subdivisions::
>>> Country = Model.get('country.country')
>>> Subdivision = Model.get('country.subdivision')
>>> spain = Country(name='Spain', code='ES')
>>> spain.save()
>>> catalonia = Subdivision()
>>> catalonia.code = 'ES-CAT'
>>> catalonia.name = 'Catalonia'
>>> catalonia.country = spain
>>> catalonia.type = 'autonomous community'
>>> catalonia.save()
>>> barcelona = Subdivision()
>>> barcelona.code = 'ES-BCN'
>>> barcelona.name = 'Barcelona'
>>> barcelona.country = spain
>>> barcelona.type = 'province'
>>> barcelona.parent = catalonia
>>> barcelona.save()
>>> madrid = Subdivision()
>>> madrid.code = 'ES-MAD'
>>> madrid.name = 'Madrid'
>>> madrid.country = spain
>>> madrid.type = 'province'
>>> madrid.save()
Create customers::
>>> Party = Model.get('party.party')
>>> customer = Party(name='Customer')
>>> address, = customer.addresses
>>> address.country = spain
>>> address.subdivision = madrid
>>> customer.save()
>>> other_customer = Party(name='Other Customer')
>>> address, = other_customer.addresses
>>> address.country = spain
>>> address.subdivision = barcelona
>>> other_customer.save()
Create product::
>>> ProductUom = Model.get('product.uom')
>>> ProductTemplate = Model.get('product.template')
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> template = ProductTemplate()
>>> template.name = 'Product'
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.salable = True
>>> template.list_price = Decimal('20')
>>> template.save()
>>> product, = template.products
>>> carrier_template = ProductTemplate()
>>> carrier_template.name = 'Carrier Product'
>>> carrier_template.default_uom = unit
>>> carrier_template.type = 'service'
>>> carrier_template.salable = True
>>> carrier_template.list_price = Decimal('3')
>>> carrier_template.save()
>>> carrier_product, = carrier_template.products
Create carriers::
>>> Carrier = Model.get('carrier')
>>> carrier = Carrier()
>>> party = Party(name='Carrier')
>>> party.save()
>>> carrier.party = party
>>> carrier.carrier_product = carrier_product
>>> carrier.save()
>>> catalan_carrier = Carrier()
>>> party = Party(name='Catalan Carrier')
>>> party.save()
>>> catalan_carrier.party = party
>>> catalan_carrier.carrier_product = carrier_product
>>> catalan_carrier.save()
Set subdivision for each carrier::
>>> CarrierSelection = Model.get('carrier.selection')
>>> csc = CarrierSelection()
>>> csc.carrier = catalan_carrier
>>> csc.to_country = spain
>>> csc.to_subdivision = catalonia
>>> csc.sequence = 10
>>> csc.save()
>>> csc = CarrierSelection()
>>> csc.carrier = carrier
>>> csc.to_country = spain
>>> csc.sequence = 20
>>> csc.save()
Test right carrier is used on sale::
>>> Sale = Model.get('sale.sale')
>>> sale = Sale()
>>> sale.party = customer
>>> assertEqual(sale.carrier, carrier)
>>> sale.carrier = None
>>> sale.party = other_customer
>>> assertEqual(sale.carrier, catalan_carrier)

View File

@@ -0,0 +1,91 @@
========================================
Carrier Subdivision Postal Code Scenario
========================================
Imports::
>>> from decimal import Decimal
>>> from proteus import Model
>>> from trytond.modules.company.tests.tools import create_company
>>> from trytond.tests.tools import activate_modules, assertEqual
Activate modules::
>>> config = activate_modules(
... ['carrier_subdivision', 'sale_shipment_cost'], create_company)
Create customers::
>>> Party = Model.get('party.party')
>>> customer = Party(name='Customer')
>>> address, = customer.addresses
>>> address.postal_code = '08080'
>>> customer.save()
>>> other_customer = Party(name='Other Customer')
>>> address, = other_customer.addresses
>>> address.postal_code = '25175'
>>> other_customer.save()
Create product::
>>> ProductUom = Model.get('product.uom')
>>> ProductTemplate = Model.get('product.template')
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> template = ProductTemplate()
>>> template.name = 'Product'
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.salable = True
>>> template.list_price = Decimal('20')
>>> template.save()
>>> product, = template.products
>>> carrier_template = ProductTemplate()
>>> carrier_template.name = 'Carrier Product'
>>> carrier_template.default_uom = unit
>>> carrier_template.type = 'service'
>>> carrier_template.salable = True
>>> carrier_template.list_price = Decimal('3')
>>> carrier_template.save()
>>> carrier_product, = carrier_template.products
Create carriers::
>>> Carrier = Model.get('carrier')
>>> carrier = Carrier()
>>> party = Party(name='Carrier')
>>> party.save()
>>> carrier.party = party
>>> carrier.carrier_product = carrier_product
>>> carrier.save()
>>> local_carrier = Carrier()
>>> party = Party(name='Local Carrier')
>>> party.save()
>>> local_carrier.party = party
>>> local_carrier.carrier_product = carrier_product
>>> local_carrier.save()
Create postal code selection for each carrier::
>>> CarrierSelection = Model.get('carrier.selection')
>>> csc = CarrierSelection()
>>> csc.carrier = local_carrier
>>> csc.to_postal_code = '25'
>>> csc.sequence = 10
>>> csc.save()
>>> csc = CarrierSelection()
>>> csc.carrier = carrier
>>> csc.sequence = 20
>>> csc.save()
Test right carrier is used on sale::
>>> Sale = Model.get('sale.sale')
>>> sale = Sale()
>>> sale.party = customer
>>> assertEqual(sale.carrier, carrier)
>>> sale.carrier = None
>>> sale.party = other_customer
>>> assertEqual(sale.carrier, local_carrier)

View File

@@ -0,0 +1,13 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.tests.test_tryton import ModuleTestCase
class CarrierSubdivisionTestCase(ModuleTestCase):
"Test Carrier Subdivision module"
module = 'carrier_subdivision'
extras = ['carrier_carriage', 'sale_shipment_cost']
del ModuleTestCase

View File

@@ -0,0 +1,8 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.tests.test_tryton import load_doc_tests
def load_tests(*args, **kwargs):
return load_doc_tests(__name__, __file__, *args, **kwargs)

View File

@@ -0,0 +1,23 @@
[tryton]
version=7.8.0
depends:
carrier
country
ir
extras_depend:
carrier_carriage
sale_shipment_cost
xml:
carrier.xml
[register]
model:
carrier.Selection
[register carrier_carriage sale_shipment_cost]
model:
sale.Carriage
[register sale_shipment_cost]
model:
sale.Sale

View File

@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="/form/field[@name='from_country']" position="after">
<label name="from_subdivision"/>
<field name="from_subdivision"/>
<label name="from_postal_code"/>
<field name="from_postal_code"/>
<newline/>
</xpath>
<xpath expr="/form/field[@name='to_country']" position="after">
<label name="to_subdivision"/>
<field name="to_subdivision"/>
<label name="to_postal_code"/>
<field name="to_postal_code"/>
<newline/>
</xpath>
</data>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="/tree/field[@name='from_country']" position="after">
<field name="from_subdivision" optional="1"/>
<field name="from_postal_code" optional="1"/>
</xpath>
<xpath expr="/tree/field[@name='to_country']" position="after">
<field name="to_subdivision" optional="1"/>
<field name="to_postal_code" optional="1"/>
</xpath>
</data>