Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

How to add a reduction amount to the amount total in POS order

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
ordertotalamountcoupon
5422 Visualizzazioni
Avatar
Matthieu

Hello,

I'm currently trying to add my attribute "coupon_nb" (the amount of reduction given to a customer) to the amount total in pos.order.

My code is here :

class loyalty_reward(osv.osv):

_name = 'loyalty.reward'

_columns = {

'name': fields.char('Name', size=32, select=1, required=True, help='An internal identification for this loyalty reward'),

'loyalty_program_id': fields.many2one('loyalty.program', 'Loyalty Program', help='The Loyalty Program this reward belongs to'),

'minimum_points': fields.float('Minimum Points', help='The minimum amount of points the customer must have to qualify for this reward'),

'type': fields.selection((('gift','Gift'),('discount','Discount'),('resale','Resale')), 'Type', required=True, help='The type of the reward'),

'gift_product_id': fields.many2one('product.product','Gift Product', help='The product given as a reward'),

'point_cost': fields.float('Point Cost', help='The cost of the reward'),

'discount_product_id': fields.many2one('product.product','Discount Product', help='The product used to apply discounts'),

'discount': fields.float('Discount',help='The discount percentage'),

'point_product_id': fields.many2one('product.product', 'Point Product', help='The product that represents a point that is sold by the customer'),

}

def _check_gift_product(self, cr, uid, ids, context=None):

for reward in self.browse(cr, uid, ids, context=context):

if reward.type == 'gift':

return bool(reward.gift_product_id)

else:

return True

def _check_discount_product(self, cr, uid, ids, context=None):

for reward in self.browse(cr, uid, ids, context=context):

if reward.type == 'discount':

return bool(reward.discount_product_id)

else:

return True

def _check_point_product(self, cr, uid, ids, context=None):

for reward in self.browse(cr, uid, ids, context=context):

if reward.type == 'resale':

return bool(reward.point_product_id)

else:

return True

_constraints = [

(_check_gift_product, "The gift product field is mandatory for gift rewards", ["type","gift_product_id"]),

(_check_discount_product, "The discount product field is mandatory for discount rewards", ["type","discount_product_id"]),

(_check_point_product, "The point product field is mandatory for point resale rewards", ["type","discount_product_id"]),

]

<record model="ir.ui.view" id="view_pos_pos_form">

<field name="name">pos.order.inherit</field>

<field name="model">pos.order</field>

<field name="inherit_id" ref="point_of_sale.view_pos_pos_form"/>

<field name="arch" type="xml">

<xpath expr="//page[@name='extra']" position="inside">

<group name="loyalty" string="Loyalty Programs">

<field name="loyalty_points" />

<field name="coupon_nb" />

</group>

</xpath>

</field>

</record>

 Here I have loyalty_points and coupon_nb that are visible.

But I want coupon_nb to be used to calculate the amount total.

Here you can see the result :

http://i.imgur.com/yGbwoSN.png

But as you can see here,  the amount total doesn't change at all :

http://i.imgur.com/NMcc8TE.png


Please, help me.

0
Avatar
Abbandona
Matthieu
Autore

I failed, the right python code is this : class pos_order(osv.osv): _inherit = 'pos.order' _columns = { 'loyalty_points': fields.float('Loyalty Points', help='The amount of Loyalty points the customer won or lost with this order'), 'coupon_nb': fields.float('Coupon Reduction', help='Coupon amount reduction'), } def _order_fields(self, cr, uid, ui_order, context=None): fields = super(pos_order,self)._order_fields(cr,uid,ui_order,context) fields['loyalty_points'] = ui_order.get('loyalty_points',0) fields['coupon_nb'] = ui_order.get('coupon_nb',0) return fields def _amount_all(self, cr, uid, ids, field_name, arg, context=None): res = super(sale_order, self)._amount_all(cr, uid, ids, field_name, arg, context) for order in self.browse(cr, uid, ids, context=context): res[order.id]['amount_total'] += order.amount_total + order.coupon_nb return res def create_from_ui(self, cr, uid, orders, context=None): ids = super(pos_order,self).create_from_ui(cr,uid,orders,context=context) for order in orders: if order['data']['coupon_nb'] != 0: orderT = self.pool.get('pos.order').browse(cr, uid, ids, context=context) orderT.write({'coupon_nb': order['data']['coupon_nb']}) if order['data']['loyalty_points'] != 0 and order['data']['partner_id']: partner = self.pool.get('res.partner').browse(cr,uid,order['data']['partner_id'], context=context) partner.write({'loyalty_points': partner['loyalty_points'] + order['data']['loyalty_points']}) return ids

Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
How to modify amount_total from pos_order
order total amount
Avatar
Avatar
Avatar
4
mag 16
5565
How to edit Total value from order form Risolto
order total
Avatar
Avatar
Avatar
15
mag 16
7990
Discount for the amount of the order?
discount order amount
Avatar
Avatar
2
apr 23
5348
How to get the field values from another module?
total amount saleorder
Avatar
Avatar
2
mar 20
13406
PO does not show received quantity
purchase order quantity total received
Avatar
Avatar
2
set 22
5328
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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