Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Filter Delivery Methods by custom zones

Subscriure's

Get notified when there's activity on this post

This question has been flagged
salespartnerdeliveryorderwebsite_sale
1 Respondre
2150 Vistes
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
Descartar
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

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
Descartar
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
Different delivery orders for a single Order
sales delivery order
Avatar
Avatar
1
de set. 16
7173
Ho do I delete a delivery order?
sales delivery order
Avatar
Avatar
1
de març 15
9705
How to reference a delivery order line to sales order line?
sales delivery order line
Avatar
Avatar
1
d’oct. 15
10058
Cancel Sales Order after Delivered Items
sales delivery cancel order products
Avatar
Avatar
Avatar
Avatar
Avatar
14
de set. 24
40079
Edit Sales Order after a delivery has been done Solved
sales delivery
Avatar
Avatar
1
de maig 23
6713
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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