Skip to content

Commit 294ceb0

Browse files
cede-odooprbo-odoo
authored andcommitted
[ADD] website airproof: add solution for website theme tutorial
closes odoo#764 Signed-off-by: Antoine Vandevenne (anv) <[email protected]>
1 parent 4c650f3 commit 294ceb0

File tree

80 files changed

+3253
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+3253
-0
lines changed

salesperson_in_pos/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
from . import models

salesperson_in_pos/__manifest__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
'name': "Salesperson_Pos",
3+
'version': "1.0",
4+
'summary': "Add salesperson field in POS app",
5+
'description': "This module adds a button in the POS dashboard to assign a salesperson to respective orders.",
6+
'author': "Priyansi Borda",
7+
'depends': ['base', 'point_of_sale', 'hr'],
8+
'data': [
9+
"views/pos_view.xml",
10+
],
11+
'assets': {
12+
'point_of_sale._assets_pos': [
13+
'salesperson_in_pos/static/src/**/*',
14+
],
15+
},
16+
'application': False,
17+
'installable': True,
18+
'license': 'LGPL-3',
19+
}

salesperson_in_pos/models/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
from . import pos_order
3+
from . import pos_session
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from odoo import models, fields
2+
3+
4+
class PosOrder(models.Model):
5+
_inherit = "pos.order"
6+
7+
salesperson_id = fields.Many2one('hr.employee', string='Salesperson', help='Salesperson who created the order')
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from odoo import models
2+
3+
4+
class PosSession(models.Model):
5+
_inherit = 'pos.session'
6+
7+
def _load_pos_data_models(self, config_id):
8+
data = super()._load_pos_data_models(config_id)
9+
data.append("hr.employee")
10+
return data
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { patch } from "@web/core/utils/patch";
2+
import { ControlButtons } from "@point_of_sale/app/screens/product_screen/control_buttons/control_buttons";
3+
import { SelectSalespersonButton } from "@salesperson_in_pos/salesperson_button/salesperson_button";
4+
5+
patch(ControlButtons, {
6+
components: {
7+
...ControlButtons.components,
8+
SelectSalespersonButton,
9+
},
10+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<templates id="template" xml:space="preserve">
3+
<t t-name="pos_salesperson_assignment.ControlButtons" t-inherit="point_of_sale.ControlButtons" t-inherit-mode="extension">
4+
<xpath expr="//button[@t-if='!props.showRemainingButtons and !ui.isSmall and props.onClickMore']" position="before">
5+
<SelectSalespersonButton/>
6+
</xpath>
7+
</t>
8+
</templates>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { patch } from "@web/core/utils/patch";
2+
import { PosOrder } from "@point_of_sale/app/models/pos_order";
3+
4+
patch(PosOrder.prototype, {
5+
setSalesperson(sales_person) {
6+
this.update({ salesperson: sales_person });
7+
},
8+
getSalesperson(){
9+
return this.salesperson;
10+
},
11+
});
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { Component } from "@odoo/owl";
2+
import { usePos } from "@point_of_sale/app/store/pos_hook";
3+
import { useService } from "@web/core/utils/hooks";
4+
import { _t } from "@web/core/l10n/translation";
5+
import { makeAwaitable } from "@point_of_sale/app/store/make_awaitable_dialog";
6+
import { SelectionPopup } from "@point_of_sale/app/utils/input_popups/selection_popup";
7+
8+
export class SelectSalespersonButton extends Component {
9+
static template = "point_of_sale.SelectSalespersonButton";
10+
static props = ["salesperson?"]
11+
setup() {
12+
this.pos = usePos();
13+
this.dialog = useService("dialog");
14+
const salesperson = this.pos.get_order()?.getSalesperson();
15+
if (salesperson) {
16+
this.props.salesperson = salesperson;
17+
}
18+
}
19+
20+
async selectSalesperson(){
21+
const currentOrder = this.pos.get_order();
22+
if (!currentOrder) return;
23+
const salesperson_list = this.pos.models['hr.employee'].map((sp) => {
24+
return {
25+
id: sp.id,
26+
item: sp,
27+
label: sp.name,
28+
isSelected: currentOrder.getSalesperson()?.id === sp.id
29+
}
30+
});
31+
const selectedSalesperson = await makeAwaitable(this.dialog, SelectionPopup, {
32+
title: _t("Select salesperson"),
33+
list: salesperson_list,
34+
});
35+
if (selectedSalesperson) return;
36+
const same = currentOrder.getSalesperson()?.id === selected.id;
37+
this.props.salesperson = same ? null : selected;
38+
order.setSalesperson(same ? "" : selected);
39+
}
40+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<templates id="temnplate" xml:space="preserve">
2+
<t t-name="point_of_sale.SelectSalespersonButton">
3+
<button class="btn btn-light btn-lg lh-lg text-truncate w-auto" t-on-click="() => this.selectSalesperson()">
4+
<div t-if="props.salesperson" t-esc="props.salesperson.name" class="text-truncate text-action"></div>
5+
<div t-else="">
6+
Salesperson
7+
</div>
8+
</button>
9+
</t>
10+
</templates>

0 commit comments

Comments
 (0)