Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Kov
    • Nábytek
    • Jídlo
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • IT hardware a podpora
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

Add a field and update the value in odoo pos orderline Odoo 11

Odebírat

Get notified when there's activity on this post

This question has been flagged
javascriptinheritancepoint_of_saleodooodoo11
1 Odpovědět
16878 Zobrazení
Avatar
Kabeer KB

I am trying to add a new field in pos order line and update the value in button click.


**pos.oerder.line.py**


    

    class pos_order_line(models.Model):

        _inherit = 'pos.order.line'

        is_promo = fields.Boolean(string='Promo',default=False)


***.js**


    models.Orderline = models.Orderline.extend({


    initialize: function() {

      _super_orderline.initialize.apply(this,arguments);

      this.is_promo = false;

    },


    // Help me to understand this function

    export_as_JSON: function(){ 

        var json = _super_orderline.export_as_JSON.apply(this,arguments);

        json.is_promo = this.is_promo;

        return json;

    },


    // Help me to understand this function

    init_from_JSON: function(json){

        _super_orderline.init_from_JSON.apply(this,arguments);

        this.is_promo = json.is_promo;

    },

  

    });


    var OfferButton = screens.ActionButtonWidget.extend({

    'template': 'PromotioanlButton',

    button_click: function(){

        var self = this;

        self.get_promo_config();

    },



    get_promo_config: function () {

      var self = this;

      var order    = this.pos.get_order();

      var orderline = order.get_orderlines();

      var order_product_ids = []

      _.each(orderline,function(line){

        order_product_ids.push({'product_id':line.product.id,'qty':line.quantity});

      });


      rpc.query({

        model:'promo.config',

        method:'check_promo_offer',

        args :[order_product_ids],

      }).then(function(product_ids){


        _.each(product_ids, function(pid){

          var product  = self.pos.db.get_product_by_id(pid.product_id);



     **// I added new item into cart using below code and its working fine. 

     //It add all the fields below mention except `is_promo`, i mean it still false. 

      //how can i make it true.**

          order.add_product(product, { price:0.0 ,quantity:pid.product_uom_qty,discount:25,is_promo:true,merge:false});

      });

      });

    },

    });




Please suggest any solution.


0
Avatar
Zrušit
shalin wilson

<?xml version="1.0" encoding="UTF-8"?>

<templates id="template" xml:space="preserve">

<t t-extend="Orderline">

<t t-jquery="ul[class*='info-list']" t-operation="append">

<li class="info orderline-note">

<i class="fa fa-caret-right"/>Note

</li>

</t>

</t>

</templates>

Avatar
Pranav P S
Nejlepší odpověď

In button click make is_promo true:


    button_click: function(){

        this.is_promo = true;

    }


And in product selection or change, update the lines:


var models = require('point_of_sale.models');
var _super_Order = models.Order.prototype;
models.Order = models.Order.extend({
export_as_JSON: function () {
var json = _super_Order.export_as_JSON.apply(this, arguments);
    if (json.lines){
        ......
        your logic
        ......
        json.lines[j][2].is_promo = this.is_promo;
    }
}

* No need of init_from_JSON

*Export as json will regenerate the order lines(JSON) on product selection/removal/updation etc

1
Avatar
Zrušit
Kabeer KB
Autor

@Pranav, what is `j` in this line, `json.lines[j][2].is_promo = this.is_promo;`

And i think it will update `is_promo` for all orderlines, right?

Pranav P S

'j' i meant for line number, you can replace 'j' with actual line number.

Kabeer KB
Autor

I changed to this `var len = json.lines.length

json.lines[len-1][2].is_promo = true;`

But in the view it didnt change the value.

Pranav P S

No it will not change the view, this json is to pass value to odoo backend.

Kabeer KB
Autor

But i want it to change it in the view too.

Pranav P S

How and where you have to display in view?

Kabeer KB
Autor

I updated my question with a screen shot.

Pranav P S

Please refer <t t-name="Orderline"> in pos.xml.

Extend view and add your method to return this.is_promo value in models.js same as below.

Eg:

pos.xml

<t t-esc="line.get_quantity_str()" />

models.js:

get_quantity_str: function(){

return this.quantityStr;

},

Enjoying the discussion? Don't just read, join in!

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
How add field in current pos order from JavaScript Odoo 11 Vyřešeno
javascript order point_of_sale odoo odoo11
Avatar
Avatar
Avatar
2
kvě 21
8611
Override a javascript function in Odoo 11? Vyřešeno
javascript odoo odoo11
Avatar
Avatar
Avatar
Avatar
3
kvě 22
9856
Inherit the RewardButton class Js point of sale
javascript point_of_sale odoo owl
Avatar
Avatar
1
pro 23
2429
Point of sale image src call javaScript variable
javascript pos point_of_sale odoo11
Avatar
0
bře 19
4067
Inherit POS Javascript function in Odoo 10 Vyřešeno
javascript inheritance point_of_sale odoo10.0
Avatar
Avatar
1
dub 18
11431
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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