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

automate sales counter in the model

Odoberať

Get notified when there's activity on this post

This question has been flagged
odooPythonodoo12
3067 Zobrazenia
Avatar
AZCHILENO .

I am trying to make an automation in my model through code but I don't know if I am missing something because I add what I found on Google but at the end of a month it is not restored. I wish that through an accountant that I already have the method count the sales made in a month, that currently makes it but at the end of the month it continues adding the sales of the previous month and that I do not want, since the idea is that at the end of a month sales made in a month resume and start at 0. The code I have is as follows:


<data noupdate = "1">

        <record forcecreate = "True" id = "vendor_monthly_counter" model = "ir.cron">
           <field name = "name"> Monthly worker accountant </field>
           <field eval = "True" name = "active" />
           <field name = "user_id" ref = "base.user_root" />
           <field name = "interval_number"> 1 </field>
           <field name = "interval_type"> months </field>
           <field name = "numbercall"> - 1 </field>
           <field ref = "model_proyecto_rc_trabajador" name = "model_id" />
            <field name = "state"> code </field>
           <field name = "code"> model.get_realized_sales () </field>
           <field eval = "False" name = "doall" />
           <field name = "function"> True </field

py get_realized_sales

class worker(models.Model):
    _name = 'project_rc.worker'
    _rec_name = 'name'

    name = fields.Char(string="Name", required=True)
    charge = fields.Selection(
        [('seller', 'Seller'), ('cashier', 'Cashier')],
        string="Cargo", required=True)
    sales_counter = fields.Integer(
        string="Sales made", compute="get_realized_sales", store=True)
    document_ids = fields.One2many(
        comodel_name='project_rc.document', inverse_name='worker_id',
        string='Invoice', required=true)

    @api.depends ('document_ids')
    def get_realized_sales(self):
        for rec in self:
            document = rec.document_ids.filtered(
                lambda r: r.type_movimiento_id and\
                    r.type_movement_id.type_movement == 'sale')
            rec.sales_counter = len(document)

What could I miss, some py? and how would that py be?


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
Executing Python Script in Odoo
odoo Python
Avatar
Avatar
Avatar
2
aug 25
16828
How to track One2many field in Odoo12? Solved
odoo odoo12
Avatar
Avatar
Avatar
Avatar
3
nov 23
18391
Error: Couldn't load module web Solved
odoo odoo12
Avatar
Avatar
Avatar
3
nov 24
26493
How I get the current ID of a record ? Solved
odoo odoo12
Avatar
Avatar
1
apr 23
6890
Binary field as attachment in mail in Odoo 13 Solved
odoo odoo12
Avatar
Avatar
2
dec 22
7775
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