-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '14.0' of https://github.com/odoomates/odooapps into 14.0
- Loading branch information
Showing
15 changed files
with
292 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
{ | ||
'name': 'Pos Service Charge', | ||
'version': '14.0.1.0.0', | ||
'category': 'Point of Sale', | ||
'summary': 'Service Charges In POS', | ||
'description': """Service charges in pos""", | ||
'depends': ['point_of_sale'], | ||
'author': 'Odoo Mates, Sempai Space', | ||
'company': 'Odoo Mates, Sempai Space', | ||
'maintainer': 'Odoo Mates, Sempai Space', | ||
'website': 'http://odoomates.tech, https://www.sempai.space', | ||
'support': 'odoomates@gmail.com, sempaispace@gmail.com', | ||
'data': [ | ||
'views/pos.xml', | ||
'views/pos_templates.xml' | ||
], | ||
'qweb': [ | ||
'static/src/xml/PosServiceChargeButton.xml', | ||
], | ||
'images': ['static/description/banner.png'], | ||
'license': 'LGPL-3', | ||
'installable': True, | ||
'auto_install': False, | ||
'application': False, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import pos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class PosConfig(models.Model): | ||
_inherit = 'pos.config' | ||
|
||
enable_service_charge = fields.Boolean(string='Service Charges') | ||
service_charge_tax_calculation = fields.Boolean(string='Include taxes for calculation?',required=True,default=True) | ||
service_charge_type = fields.Selection([('amount', 'Amount'), | ||
('percentage', 'Percentage')], | ||
string='Type', default='amount') | ||
service_charge = fields.Float(string='Service Charge') | ||
service_product_id = fields.Many2one('product.product', string='Service Product', | ||
domain="[('available_in_pos', '=', True)," | ||
"('sale_ok', '=', True), ('type', '=', 'service')]") | ||
|
||
@api.onchange('enable_service_charge') | ||
def set_config_service_charge(self): | ||
if self.enable_service_charge: | ||
if not self.service_product_id: | ||
domain = [('available_in_pos', '=', True), ('sale_ok', '=', True), ('type', '=', 'service')] | ||
self.service_product_id = self.env['product.product'].search(domain, limit=1) | ||
self.service_charge = 10.0 | ||
else: | ||
self.service_product_id = False | ||
self.service_charge = 0.0 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<section class="oe_container oe_dark"> | ||
<div class="col-md-12"> | ||
<h2 class="oe_slogan" style="font-size: 35px;color:#2C0091"><b>Pos Service Charge</b></h2> | ||
</div> | ||
</section> | ||
|
||
<section class="oe_container"> | ||
<div class="oe_row oe_spaced"> | ||
<div style="text-align:center;"> | ||
<h1 style=" text-align: center;"> | ||
<span align="center" style="color:#148963;"> | ||
<span class="fa fa-star fa-spin"> | ||
</span> | ||
Features:</span> | ||
</h1> | ||
<p class="fa fa-hand-o-right" style="color:CRIMSON;font-size: 25px;"> | ||
<span style="color:#2dd280;font-size: 15px;">Percentage / Amount Service Charges( Configurable )</span> | ||
</p><br/> | ||
<p class="fa fa-hand-o-right" style="color:CRIMSON;font-size: 25px;"> | ||
<span style="color:#2dd280;font-size: 15px;">Edit and Apply charges from pos.</span> | ||
</p><br/> | ||
|
||
</div> | ||
<br/> | ||
</div> | ||
</section> | ||
|
||
|
||
<section class="oe_container oe_dark"> | ||
<div class="oe_row oe_spaced"> | ||
<h3 class="oe_slogan" style="color:#1b1d26;">Pos Configuration</h3> | ||
<div class="oe_demo oe_picture oe_screenshot"> | ||
<img src="pos_config.png"> | ||
</div> | ||
</div> | ||
</section> | ||
|
||
|
||
<section class="oe_container"> | ||
<div class="oe_row oe_spaced"> | ||
<h3 class="oe_slogan" style="color:#1b1d26;">Service Charge in Pos</h3> | ||
<div class="oe_demo oe_picture oe_screenshot"> | ||
<img src="pos_service_charge.png"> | ||
</div> | ||
</div> | ||
</section> | ||
|
||
|
||
|
||
<hr style="width: 100%;height: 4px;background: #2C0091;margin: 0px 0px;"> | ||
<hr style="width: 100%;height: 4px;background: #148963;margin: 0px 0px;"> | ||
<section class="oe_container oe_dark"> | ||
<div class="oe_row "> | ||
<div class="oe_slogan text-center"> | ||
<img src="odoo_mates.png"/> | ||
<div style="color:#269900;"> | ||
<h3 style="color:#2C0091;font-size: 25px;">If you need any support or want more features, just contact us:</h3><br> | ||
<h3 style="color:#2C0091;font-size: 20px;">Email: <a href="odoomates@gmail.com">odoomates@gmail.com</a> <br></h3> | ||
</div> | ||
<div class="oe_slogan"> | ||
<h2> | ||
<a target="_blank" href="https://www.facebook.com/odoomate/" target="new"> | ||
<i class="fa fa-facebook-square" style="font-size:38px;"></i> | ||
</a> | ||
<a target="_blank" href="https://twitter.com/odoomates/" target="new"> | ||
<i class="fa fa-twitter" style="font-size:38px;"></i> | ||
</a> | ||
<a href="#" target="_blank"> | ||
<i class="fa fa-linkedin" style="font-size:38px;"></i> | ||
</a> | ||
<a target="_blank" href="https://www.youtube.com/channel/UCVKlUZP7HAhdQgs-9iTJklQ"> | ||
<i class="fa fa-youtube-play" style="font-size:38px;"></i> | ||
</a> | ||
</h2> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
<hr style="width: 100%;height: 4px;background: #148963;margin: 0px 0px;"> | ||
<hr style="width: 100%;height: 4px;background: #2C0091;margin: 0px 0px;"> | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
87 changes: 87 additions & 0 deletions
87
om_pos_service_charge/static/src/js/PosServiceChargeButton.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
odoo.define("pos_order_to_purchase_order.PosServiceChargeButton", function (require) { | ||
"use strict"; | ||
|
||
const PosComponent = require("point_of_sale.PosComponent"); | ||
const ProductScreen = require("point_of_sale.ProductScreen"); | ||
const {useListener} = require("web.custom_hooks"); | ||
const Registries = require("point_of_sale.Registries"); | ||
const {_t} = require("web.core"); | ||
|
||
class PosServiceChargeButton extends PosComponent { | ||
constructor() { | ||
super(...arguments); | ||
useListener("click", this.onClick); | ||
} | ||
async onClick() { | ||
var self = this; | ||
var service_amount_type = this.env.pos.config.service_charge_type; | ||
var order = this.env.pos.get_order(); | ||
var lines = order.get_orderlines(); | ||
var product = this.env.pos.db.get_product_by_id(this.env.pos.config.service_product_id[0]); | ||
if (!lines.length) { | ||
return this.showPopup("ErrorPopup", { | ||
title: _t("Empty Order"), | ||
body: _t("You need add some products"), | ||
}); | ||
} | ||
if (product === undefined) { | ||
return this.showPopup("ErrorPopup", { | ||
title: _t("No service product found"), | ||
body: _t("The service product seems misconfigured. Make sure it is flagged as 'Can be Sold' and 'Available in Point of Sale'."), | ||
}); | ||
} | ||
var i = 0; | ||
while ( i < lines.length ) { | ||
if (lines[i].get_product() === product) { | ||
order.remove_orderline(lines[i]); | ||
} else { | ||
i++; | ||
} | ||
} | ||
|
||
if (service_amount_type == 'amount'){ | ||
const {confirmed, payload} = await this.showPopup("NumberPopup", { | ||
title: this.env._t("Service Charge"), | ||
startingValue: this.env.pos.config.service_charge, | ||
}); | ||
if (confirmed){ | ||
if (payload > 0){ | ||
order.add_product(product, { price: payload }); | ||
} | ||
} | ||
} | ||
if (service_amount_type == 'percentage'){ | ||
const {confirmed, payload} = await this.showPopup("NumberPopup", { | ||
title: this.env._t("Service Charge %"), | ||
startingValue: this.env.pos.config.service_charge, | ||
}); | ||
if (confirmed){ | ||
if ( this.env.pos.config.service_charge_tax_calculation) { | ||
var service_charge = payload / 100.0 * order.get_total_with_tax(); | ||
if (service_charge > 0){ | ||
order.add_product(product, { price: service_charge }); | ||
} | ||
} | ||
else { | ||
var service_charge = payload / 100.0 * order.get_total_without_tax(); | ||
if (service_charge > 0){ | ||
order.add_product(product, { price: service_charge }); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
PosServiceChargeButton.template = "PosServiceChargeButton"; | ||
|
||
ProductScreen.addControlButton({ | ||
component: PosServiceChargeButton, | ||
condition: function () { | ||
return this.env.pos.config.enable_service_charge; | ||
}, | ||
}); | ||
|
||
Registries.Component.add(PosServiceChargeButton); | ||
|
||
return PosServiceChargeButton; | ||
}); |
11 changes: 11 additions & 0 deletions
11
om_pos_service_charge/static/src/xml/PosServiceChargeButton.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates id="template" xml:space="preserve"> | ||
<t t-name="PosServiceChargeButton" owl="1"> | ||
<span class="control-button js_service_charge"> | ||
<i class="fa fa-pencil-square-o" /> | ||
<span> </span> | ||
<span>Service Charge</span> | ||
</span> | ||
</t> | ||
|
||
</templates> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<record id="pos_service_charge_config_form" model="ir.ui.view"> | ||
<field name="name">pos.config.form.service.charge</field> | ||
<field name="model">pos.config</field> | ||
<field name="inherit_id" ref="point_of_sale.pos_config_view_form" /> | ||
<field name="arch" type="xml"> | ||
<div id="pricelist_setting" position="after"> | ||
<div class="col-xs-12 col-lg-6 o_setting_box" > | ||
<div class="o_setting_left_pane"> | ||
<field name="enable_service_charge"/> | ||
</div> | ||
<div class="o_setting_right_pane"> | ||
<label for="enable_service_charge"/> | ||
<div class="text-muted"> | ||
Allow service charges on orders | ||
</div> | ||
<div class="content-group " attrs="{'invisible':[('enable_service_charge','=',False)]}"> | ||
<div class="row"> | ||
<label for="service_charge_type" class="col-lg-3 o_light_label"/> | ||
<field name="service_charge_type" widget="radio" options="{'horizontal': true}" | ||
class="o_light_label" attrs="{'required':[('enable_service_charge','=',True)]}"/> | ||
</div> | ||
<div class="row mt16"> | ||
<label for="service_product_id" class="col-lg-3 o_light_label"/> | ||
<field name="service_product_id" | ||
attrs="{'required':[('enable_service_charge','=',True)]}"/> | ||
</div> | ||
<div class="row mt16"> | ||
<label for="service_charge_tax_calculation" class="col-lg-3 o_light_label"/> | ||
<field name="service_charge_tax_calculation" | ||
attrs="{'required':[('enable_service_charge','=',True)]}"/> | ||
</div> | ||
<div class="row"> | ||
<label for="service_charge" class="col-lg-3 o_light_label"/> | ||
<field name="service_charge"/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</field> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<template id="assets" inherit_id="point_of_sale.assets"> | ||
<xpath expr="." position="inside"> | ||
<script type="text/javascript" src="/om_pos_service_charge/static/src/js/PosServiceChargeButton.js"/> | ||
</xpath> | ||
</template> | ||
</odoo> |