Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Guest House
    • Distributeur de boissons
    • Hotel
    Real Estate
    • Real Estate Agency
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consulting
    • Accounting Firm
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Solar Energy Systems
    • Cordonnier
    • Services de nettoyage
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

Filter Delivery Methods by custom zones

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
salespartnerdeliveryorderwebsite_sale
1 Répondre
2143 Vues
Avatar
Barceló

I am creating a custom module for odoo17 in which I have a res.country.zone model


I have extended the following models:


res.partner: I add the "zone_id" field


delivery.carrier: I add the zone_ids field



The partner will always have a zone_id assigned, to the delivery methods I assign the zone_ids to know what is available.



So what I want to achieve is that on the /shop/payment page only the delivery methods that contain the partner's zone_id within its list of zone_ids are shown.

zones [1,2,3,4,5]
partner A - zone_id=1


delivery_method-A - zone_ids [2, 4]

delivery_method-B - zone_ids [1, 3, 5]
delivery_method-C - zone_ids [1, 4]

for partner A should only see delivery_method-B and delivery_method-C thats are available in his area

I have tried to do it by rewriting some methods of the inherited classes but I don't get the result I need.


class DeliveryCarrier(models.Model):
    _inherit = 'delivery.carrier'

    zone_ids = fields.Many2many('res.country.zone', string='Zone')   

​ ....   
​ ....   
....

    def available_carriers(self, partner):
        return self.filtered(lambda c:
​ ​._is_available_for_order(partner.sale_order_id))

    def _is_available_for_order(self, order):
        self.ensure_one()
        order.ensure_one()
     
        if not self._match_address(order.partner_shipping_id):
            return False

        partner_zone_id = order.env.context.get('zone_id')

        if partner_zone_id and partner_zone_id not in self.zone_ids.ids:
            return False

        if self.delivery_type == 'base_on_rule':
            return self.rate_shipment(order).get('success')
        return True

class ChooseDeliveryCarrier(models.TransientModel):
    _inherit = 'choose.delivery.carrier'

    @api.depends('partner_id')
    def _compute_available_carrier(self):
        for rec in self:
            zone_id = self.env.context.get('zone_id')
            carriers = self.env['delivery.carrier'].search([]).filtered(lambda carrier: carrier._is_available_for_order(rec.order_id))
            rec.available_carrier_ids = carriers

           

 On the other hand, since I don't need it, I want to make the street, phone fields not required in the shipping address and hide the zip field in website_sale.address


I tried some things by creating a custom view like the following, to make the zip field read-only, but it didn't work, it still appears enabled:


template id="address_form_inherit" inherit_id="website_sale.address"

"//input[@name='zip']" position="attributes"

attribute name="readonly">readonly

...

​ ​

  ​



some suggest?

0
Avatar
Ignorer
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Meilleure réponse

Hi,


Try this:

<template id="address" inherit_id="website_sale.address">

        <xpath expr="//input[@name='zip']/.." position="attributes">

               <attribute name="readonly">1</attribute>

        </xpath>

</template>


Hope it helps

0
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Different delivery orders for a single Order
sales delivery order
Avatar
Avatar
1
sept. 16
7158
Ho do I delete a delivery order?
sales delivery order
Avatar
Avatar
1
mars 15
9697
How to reference a delivery order line to sales order line?
sales delivery order line
Avatar
Avatar
1
oct. 15
10051
Cancel Sales Order after Delivered Items
sales delivery cancel order products
Avatar
Avatar
Avatar
Avatar
Avatar
14
sept. 24
40067
Edit Sales Order after a delivery has been done Résolu
sales delivery
Avatar
Avatar
1
mai 23
6700
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now