Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Filter Delivery Methods by custom zones

Odoberať

Get notified when there's activity on this post

This question has been flagged
salespartnerdeliveryorderwebsite_sale
1 Odpoveď
2223 Zobrazenia
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
Zrušiť
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
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
Different delivery orders for a single Order
sales delivery order
Avatar
Avatar
1
sep 16
7245
Ho do I delete a delivery order?
sales delivery order
Avatar
Avatar
1
mar 15
9761
How to reference a delivery order line to sales order line?
sales delivery order line
Avatar
Avatar
1
okt 15
10148
Cancel Sales Order after Delivered Items
sales delivery cancel order products
Avatar
Avatar
Avatar
Avatar
Avatar
14
sep 24
40171
Edit Sales Order after a delivery has been done Solved
sales delivery
Avatar
Avatar
1
máj 23
6807
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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