-
-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] sale_financial_risk_pos_compatibility: Module added
- Loading branch information
Showing
16 changed files
with
208 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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 @@ | ||
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,23 @@ | ||
{ | ||
"name": "Sale Financial Risk Pos Compatibility", | ||
"version": "16.0.1.0.0", | ||
"category": "Sales/Point of Sale", | ||
"summary": "Sale Financial Risk Pos Compatibility", | ||
"depends": ["pos_financial_risk", "pos_order_to_sale_order"], | ||
"website": "https://github.com/OCA/pos", | ||
"author": "Cetmix,Odoo Community Association (OCA)", | ||
"maintainers": ["geomer198", "CetmixGitDrone"], | ||
"data": [ | ||
"views/res_config_settings_view.xml", | ||
], | ||
"installable": True, | ||
"assets": { | ||
"point_of_sale.assets": [ | ||
"sale_financial_risk_pos_compatibility/static/src/js/CreateOrderButton.esm.js", | ||
], | ||
"web.assets_tests": [ | ||
"sale_financial_risk_pos_compatibility/static/src/tests/tours/SaleFinancialRiskPosCompatibility.tour.js", # noqa | ||
], | ||
}, | ||
"license": "AGPL-3", | ||
} |
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,2 @@ | ||
from . import pos_config | ||
from . import res_config_settings |
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,7 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class PosConfig(models.Model): | ||
_inherit = "pos.config" | ||
|
||
active_financial_risk = fields.Boolean() |
9 changes: 9 additions & 0 deletions
9
sale_financial_risk_pos_compatibility/models/res_config_settings.py
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,9 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class ResConfigSettings(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
pos_active_financial_risk = fields.Boolean( | ||
related="pos_config_id.active_financial_risk", readonly=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,2 @@ | ||
Go to Point of Sale's settings page and activate financial risk functional for a | ||
specific PoS configuration. |
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,2 @@ | ||
This module is a bridging module between **sale_financial_risk** and **pos_order_to_sale_order**. It implements control for the Sale Orders created from POS. | ||
Same warning or blocking message will be displayed in POS as if an order was created from the backend. |
36 changes: 36 additions & 0 deletions
36
sale_financial_risk_pos_compatibility/static/src/js/CreateOrderButton.esm.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,36 @@ | ||
/** @odoo-module **/ | ||
|
||
import CreateOrderButton from "point_of_sale.CreateOrderButton"; | ||
import Registries from "point_of_sale.Registries"; | ||
import {_t} from "web.core"; | ||
|
||
export const CreateOrderRiskButton = (CreateOrderButton) => | ||
class CreateOrderRiskButton extends CreateOrderButton { | ||
async onClick() { | ||
if (!this.env.pos.config.active_financial_risk) { | ||
return super.onClick(); | ||
} | ||
const order = this.env.pos.get_order(); | ||
const partner = order.partner; | ||
if (!partner) { | ||
return super.onClick(); | ||
} | ||
const partnerFields = await this.rpc({ | ||
model: "res.partner", | ||
method: "read", | ||
args: [partner.id, ["risk_total"]], | ||
}); | ||
if ( | ||
order.get_total_with_tax() + order.get_rounding_applied() > | ||
partnerFields[0].risk_total | ||
) { | ||
return await this.showPopup("ErrorPopup", { | ||
title: _t("Cannot confirm order"), | ||
body: _t("Order total exceeds customer credit limit"), | ||
}); | ||
} | ||
return super.onClick(); | ||
} | ||
}; | ||
|
||
Registries.Component.extend(CreateOrderButton, CreateOrderRiskButton); |
73 changes: 73 additions & 0 deletions
73
...l_risk_pos_compatibility/static/src/tests/tours/SaleFinancialRiskPosCompatibility.tour.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,73 @@ | ||
odoo.define( | ||
"sale_financial_risk_pos_compatibility.SaleFinancialRiskPosCompatibility", | ||
function (require) { | ||
"use strict"; | ||
|
||
const Tour = require("web_tour.tour"); | ||
|
||
const steps = [ | ||
{ | ||
content: | ||
"Test sale_financial_risk_pos_compatibility: Waiting for loading to finish", | ||
trigger: "body:not(:has(.loader))", | ||
// eslint-disable-next-line no-empty-function | ||
run: () => {}, | ||
}, | ||
{ | ||
content: | ||
"Test sale_financial_risk_pos_compatibility: Close Opening cashbox popup", | ||
trigger: "div.opening-cash-control .button:contains('Open session')", | ||
}, | ||
{ | ||
content: | ||
"Test sale_financial_risk_pos_compatibility: Leave category displayed by default", | ||
trigger: ".breadcrumb-home", | ||
// eslint-disable-next-line no-empty-function | ||
run: () => {}, | ||
}, | ||
{ | ||
content: | ||
"Test sale_financial_risk_pos_compatibility: Order a 'Whiteboard Pen' (price 3.20)", | ||
trigger: ".product-list .product-name:contains('Whiteboard Pen')", | ||
}, | ||
{ | ||
content: | ||
"Test sale_financial_risk_pos_compatibility: Click on 'Customer' Button", | ||
trigger: "button.set-partner", | ||
}, | ||
{ | ||
content: | ||
"Test sale_financial_risk_pos_compatibility: Select a customer 'Addison Olson'", | ||
trigger: "tr.partner-line td div:contains('Addison Olson')", | ||
}, | ||
{ | ||
content: | ||
"Test sale_financial_risk_pos_compatibility: Click on 'Create Order' Button", | ||
trigger: "span.control-button span:contains('Create Order')", | ||
}, | ||
{ | ||
content: | ||
"Test sale_financial_risk_pos_compatibility: Error popup click on 'Ok' Button", | ||
trigger: "div.popup-error .button:contains('Ok')", | ||
}, | ||
{ | ||
content: | ||
"Test sale_financial_risk_pos_compatibility: Close the Point of Sale frontend", | ||
trigger: ".header-button", | ||
}, | ||
{ | ||
content: | ||
"Test sale_financial_risk_pos_compatibility: Confirm closing the frontend", | ||
trigger: ".header-button", | ||
// eslint-disable-next-line no-empty-function | ||
run: () => {}, | ||
}, | ||
]; | ||
|
||
Tour.register( | ||
"SaleFinancialRiskPosCompatibility", | ||
{test: true, url: "/pos/ui"}, | ||
steps | ||
); | ||
} | ||
); |
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 @@ | ||
from . import test_module |
16 changes: 16 additions & 0 deletions
16
sale_financial_risk_pos_compatibility/tests/test_module.py
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,16 @@ | ||
from odoo.tests import tagged | ||
|
||
from odoo.addons.point_of_sale.tests.test_frontend import TestPointOfSaleHttpCommon | ||
|
||
|
||
@tagged("post_install", "-at_install") | ||
class TestUI(TestPointOfSaleHttpCommon): | ||
def test_sale_financial_risk_pos_compatibility(self): | ||
self.main_pos_config.active_financial_risk = True | ||
self.main_pos_config.open_ui() | ||
|
||
self.start_tour( | ||
f"/pos/ui?config_id={self.main_pos_config.id}", | ||
"SaleFinancialRiskPosCompatibility", | ||
login="accountman", | ||
) |
28 changes: 28 additions & 0 deletions
28
sale_financial_risk_pos_compatibility/views/res_config_settings_view.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,28 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<odoo> | ||
|
||
<record id="res_config_settings_view_form" model="ir.ui.view"> | ||
<field name="name">res.config.settings.view.form</field> | ||
<field name="model">res.config.settings</field> | ||
<field | ||
name="inherit_id" | ||
ref="pos_order_to_sale_order.view_res_config_settings_form" | ||
/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//h2[@name='create_sale_order']" position="after"> | ||
<div class="row mt16 o_settings_container"> | ||
<div class="col-12 col-lg-6 o_setting_box"> | ||
<div class="o_setting_left_pane"> | ||
<field name="pos_active_financial_risk" /> | ||
</div> | ||
<div class="o_setting_right_pane"> | ||
<label for="pos_active_financial_risk" /> | ||
<div class="text-muted" /> | ||
</div> | ||
</div> | ||
</div> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
1 change: 1 addition & 0 deletions
1
...p/sale_financial_risk_pos_compatibility/odoo/addons/sale_financial_risk_pos_compatibility
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 @@ | ||
../../../../sale_financial_risk_pos_compatibility |
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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
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 @@ | ||
odoo-addon-pos_financial_risk @ git+https://github.com/OCA/pos.git@refs/pull/1018/head#subdirectory=setup/pos_financial_risk |