Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

Filter Delivery Methods by custom zones

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
salespartnerdeliveryorderwebsite_sale
1 Răspunde
2214 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
Imagine profil
Cybrosys Techno Solutions Pvt.Ltd
Cel mai bun răspuns

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

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Different delivery orders for a single Order
sales delivery order
Imagine profil
Imagine profil
1
sept. 16
7238
Ho do I delete a delivery order?
sales delivery order
Imagine profil
Imagine profil
1
mar. 15
9758
How to reference a delivery order line to sales order line?
sales delivery order line
Imagine profil
Imagine profil
1
oct. 15
10129
Cancel Sales Order after Delivered Items
sales delivery cancel order products
Imagine profil
Imagine profil
Imagine profil
Imagine profil
Imagine profil
14
sept. 24
40161
Edit Sales Order after a delivery has been done Rezolvat
sales delivery
Imagine profil
Imagine profil
1
mai 23
6795
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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