-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[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
prbo-odoo
wants to merge
1
commit into
odoo:18.0
Choose a base branch
from
odoo-dev:18.0-salesperson-pos-prbo
base: 18.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
from . import models | ||
This file contains hidden or 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,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', | ||
} |
This file contains hidden or 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 @@ | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
from . import pos_order | ||
from . import pos_session |
This file contains hidden or 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 models, fields | ||
|
||
|
||
class PosOrder(models.Model): | ||
_inherit = "pos.order" | ||
|
||
salesperson_id = fields.Many2one('hr.employee', string='Salesperson', help='Salesperson who created the order') |
This file contains hidden or 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,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
10
salesperson_in_pos/static/src/control_button/control_button.js
This file contains hidden or 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,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, | ||
}, | ||
}); |
8 changes: 8 additions & 0 deletions
8
salesperson_in_pos/static/src/control_button/control_button.xml
This file contains hidden or 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"?> | ||
<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> |
This file contains hidden or 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 @@ | ||
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; | ||
}, | ||
}); |
40 changes: 40 additions & 0 deletions
40
salesperson_in_pos/static/src/salesperson_button/salesperson_button.js
This file contains hidden or 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,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); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
salesperson_in_pos/static/src/salesperson_button/salesperson_button.xml
This file contains hidden or 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,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> |
This file contains hidden or 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,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> |
This file contains hidden or 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,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** | ||
 | ||
|
||
**Contact page** | ||
 | ||
|
||
**Shop page** | ||
 | ||
|
||
**Product page** | ||
 |
Empty file.
This file contains hidden or 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,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', | ||
], | ||
}, | ||
} |
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.