Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Sociale media-marketing
    • E-mailmarketing
    • Sms-marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

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

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
ordertotalamountcoupon
5478 Weergaven
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
Annuleer
Matthieu
Auteur

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

Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
How to modify amount_total from pos_order
order total amount
Avatar
Avatar
Avatar
4
mei 16
5624
How to edit Total value from order form Opgelost
order total
Avatar
Avatar
Avatar
15
mei 16
8024
Discount for the amount of the order?
discount order amount
Avatar
Avatar
2
apr. 23
5361
How to get the field values from another module?
total amount saleorder
Avatar
Avatar
2
mrt. 20
13470
PO does not show received quantity
purchase order quantity total received
Avatar
Avatar
2
sep. 22
5366
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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