Skip to content

[ADD] salesperson_in_pos: adding salesperson button in POS #883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: 18.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions salesperson_in_pos/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
19 changes: 19 additions & 0 deletions salesperson_in_pos/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
'name': "Salesperson_Pos",
'version': "1.0",
'summary': "Add salesperson field in POS app",
'description': "This module adds a button in the POS dashboard to assign a salesperson to respective orders.",
'author': "Priyansi Borda",
'depends': ['base', 'point_of_sale', 'hr'],
'data': [
"views/pos_view.xml",
],
'assets': {
'point_of_sale._assets_pos': [
'salesperson_in_pos/static/src/**/*',
],
},
'application': False,
'installable': True,
'license': 'LGPL-3',
}
3 changes: 3 additions & 0 deletions salesperson_in_pos/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import pos_order
from . import pos_session
7 changes: 7 additions & 0 deletions salesperson_in_pos/models/pos_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from odoo import models, fields


class PosOrder(models.Model):
_inherit = "pos.order"

salesperson_id = fields.Many2one('hr.employee', string='Salesperson', help='Salesperson who created the order')
10 changes: 10 additions & 0 deletions salesperson_in_pos/models/pos_session.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from odoo import models


class PosSession(models.Model):
_inherit = 'pos.session'

def _load_pos_data_models(self, config_id):
data = super()._load_pos_data_models(config_id)
data.append("hr.employee")
return data
10 changes: 10 additions & 0 deletions salesperson_in_pos/static/src/control_button/control_button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { patch } from "@web/core/utils/patch";
import { ControlButtons } from "@point_of_sale/app/screens/product_screen/control_buttons/control_buttons";
import { SelectSalespersonButton } from "@salesperson_in_pos/salesperson_button/salesperson_button";

patch(ControlButtons, {
components: {
...ControlButtons.components,
SelectSalespersonButton,
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="pos_salesperson_assignment.ControlButtons" t-inherit="point_of_sale.ControlButtons" t-inherit-mode="extension">
<xpath expr="//button[@t-if='!props.showRemainingButtons and !ui.isSmall and props.onClickMore']" position="before">
<SelectSalespersonButton/>
</xpath>
</t>
</templates>
11 changes: 11 additions & 0 deletions salesperson_in_pos/static/src/models/pos_order.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { patch } from "@web/core/utils/patch";
import { PosOrder } from "@point_of_sale/app/models/pos_order";

patch(PosOrder.prototype, {
setSalesperson(sales_person) {
this.update({ salesperson: sales_person });
},
getSalesperson(){
return this.salesperson;
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Component } from "@odoo/owl";
import { usePos } from "@point_of_sale/app/store/pos_hook";
import { useService } from "@web/core/utils/hooks";
import { _t } from "@web/core/l10n/translation";
import { makeAwaitable } from "@point_of_sale/app/store/make_awaitable_dialog";
import { SelectionPopup } from "@point_of_sale/app/utils/input_popups/selection_popup";

export class SelectSalespersonButton extends Component {
static template = "point_of_sale.SelectSalespersonButton";
static props = ["salesperson?"]
setup() {
this.pos = usePos();
this.dialog = useService("dialog");
const salesperson = this.pos.get_order()?.getSalesperson();
if (salesperson) {
this.props.salesperson = salesperson;
}
}

async selectSalesperson(){
const currentOrder = this.pos.get_order();
if (!currentOrder) return;
const salesperson_list = this.pos.models['hr.employee'].map((sp) => {
return {
id: sp.id,
item: sp,
label: sp.name,
isSelected: currentOrder.getSalesperson()?.id === sp.id
}
});
const selectedSalesperson = await makeAwaitable(this.dialog, SelectionPopup, {
title: _t("Select salesperson"),
list: salesperson_list,
});
if (selectedSalesperson) return;
const same = currentOrder.getSalesperson()?.id === selected.id;
this.props.salesperson = same ? null : selected;
order.setSalesperson(same ? "" : selected);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<templates id="temnplate" xml:space="preserve">
<t t-name="point_of_sale.SelectSalespersonButton">
<button class="btn btn-light btn-lg lh-lg text-truncate w-auto" t-on-click="() => this.selectSalesperson()">
<div t-if="props.salesperson" t-esc="props.salesperson.name" class="text-truncate text-action"></div>
<div t-else="">
Salesperson
</div>
</button>
</t>
</templates>
22 changes: 22 additions & 0 deletions salesperson_in_pos/views/pos_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<odoo>
<record id="view_pos_pos_form_inherit" model="ir.ui.view">
<field name="name">pos.order.form</field>
<field name="model">pos.order</field>
<field name="inherit_id" ref="point_of_sale.view_pos_pos_form"></field>
<field name="arch" type="xml">
<xpath expr="//group[@name='order_fields']/field[@name='fiscal_position_id']" position="after">
<field name="salesperson_id" String="Salesperson"></field>
</xpath>
</field>
</record>
<record id="view_pos_order_tree_inherit" model="ir.ui.view">
<field name="name">pos.order.list</field>
<field name="model">pos.order</field>
<field name="inherit_id" ref="point_of_sale.view_pos_order_tree"></field>
<field name="arch" type="xml">
<field name="partner_id" position="after">
<field name="salesperson_id"></field>
</field>
</field>
</record>
</odoo>
18 changes: 18 additions & 0 deletions website_airproof/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Odoo Tutorial : Build a website theme

This branch contains the code necessary for the creation of the website for our Airproof example.
Example used to illustrate the exercises given in the Odoo tutorial: Build a website theme.

Here is the final design of the 4 pages of Airproof that will be created throughout this tutorial.

**Home**
![Airproof home page](airproof-home-page.jpg)

**Contact page**
![Airproof contact page](airproof-contact-page.jpg)

**Shop page**
![Airproof shop page](airproof-shop-page.jpg)

**Product page**
![Airproof product page](airproof-product-page.jpg)
Empty file added website_airproof/__init__.py
Empty file.
49 changes: 49 additions & 0 deletions website_airproof/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
'name': 'Airproof Theme',
'description': 'Airproof Theme - Drones, modelling, camera',
'category': 'Website/Theme',
# 'version': '18.0.1.0',
'author': 'PSBE Designers',
'license': 'LGPL-3',
'depends': ['website_sale', 'website_sale_wishlist', 'website_blog', 'website_mass_mailing'],
'data': [
# Options
'data/presets.xml',
# Menu
'data/menu.xml',
# Shapes
'data/shapes.xml',
# Pages
'data/pages/home.xml',
'data/pages/contact.xml',
# Frontend
'views/website_templates.xml',
'views/website_sale_templates.xml',
'views/website_sale_wishlist_templates.xml',
# Snippets
'views/snippets/options.xml',
'views/snippets/s_airproof_carousel.xml',
# Images
'data/images.xml',
],
'assets': {
'web._assets_primary_variables': [
'website_airproof/static/src/scss/primary_variables.scss',
],
'web._assets_frontend_helpers': [
('prepend', 'website_airproof/static/src/scss/bootstrap_overridden.scss'),
],
'web.assets_frontend': [
# SCSS
'website_airproof/static/src/scss/components/mouse_follower.scss',
'website_airproof/static/src/scss/layout/header.scss',
'website_airproof/static/src/scss/pages/product_page.scss',
'website_airproof/static/src/scss/pages/shop.scss',
'website_airproof/static/src/scss/snippets/caroussel.scss',
'website_airproof/static/src/scss/snippets/newsletter.scss',
'website_airproof/static/src/snippets/s_airproof_carousel/000.scss',
# JS
'website_airproof/static/src/js/mouse_follower.js',
],
},
}
Binary file added website_airproof/airproof-contact-page.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website_airproof/airproof-home-page.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website_airproof/airproof-product-page.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website_airproof/airproof-shop-page.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading