Skip to content
Closed
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
4 changes: 2 additions & 2 deletions addons/l10n_be_pos_restaurant/models/pos_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def _create_takeaway_fiscal_position(self, config):
if takeaway_preset:
takeaway_preset.write({'fiscal_position_id': fp.id})

def _load_bar_demo_data(self):
super()._load_bar_demo_data()
def _load_bar_demo_data(self, with_demo_data=True):
super()._load_bar_demo_data(with_demo_data)
if (self.env.company.chart_template or '').startswith('be'):
ChartTemplate = self.env['account.chart.template'].with_company(self.env.company)
tax_alcohol = ChartTemplate.ref('tax_alcohol_luxury')
Expand Down
16 changes: 16 additions & 0 deletions addons/point_of_sale/data/scenarios/bakery_category_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<!-- Bakery scenario pos categories -->
<record id="pos_category_breads" model="pos.category">
<field name="name">Breads</field>
<field name="image_128" type="base64" file="point_of_sale/static/img/breads-icon.png" />
<field name="sequence">7</field>
</record>
<record id="pos_category_pastries" model="pos.category">
<field name="name">Pastries</field>
<field name="image_128" type="base64" file="point_of_sale/static/img/pastries-icon.png" />
<field name="sequence">8</field>
</record>
</data>
</odoo>
12 changes: 0 additions & 12 deletions addons/point_of_sale/data/scenarios/bakery_data.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<!-- Bakery scenario config -->
<record id="pos_category_breads" model="pos.category">
<field name="name">Breads</field>
<field name="image_128" type="base64" file="point_of_sale/static/img/breads-icon.png" />
<field name="sequence">7</field>
</record>
<record id="pos_category_pastries" model="pos.category">
<field name="name">Pastries</field>
<field name="image_128" type="base64" file="point_of_sale/static/img/pastries-icon.png" />
<field name="sequence">8</field>
</record>

<!-- Bakery products -->
<record model="product.product" id="product_wholemeal_loaf">
<field name="name">Wholemeal loaf</field>
Expand Down
29 changes: 29 additions & 0 deletions addons/point_of_sale/data/scenarios/clothes_category_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<!-- Product Category -->
<record id="product_category_clothes" model="product.category">
<field name="name">Clothes</field>
</record>

<!-- Clothes scenario pos categories -->
<record id="pos_category_upper" model="pos.category">
<field name="name">Upper body</field>
<field name="image_128" type="base64" file="point_of_sale/static/img/clothes-icon.png" />
<field name="sequence">4</field>
</record>

<record id="pos_category_lower" model="pos.category">
<field name="name">Lower body</field>
<field name="image_128" type="base64" file="point_of_sale/static/img/lower-body-icon.png" />
<field name="sequence">5</field>
</record>

<record id="pos_category_others" model="pos.category">
<field name="name">Others</field>
<field name="image_128" type="base64" file="point_of_sale/static/img/others-icon.png" />
<field name="sequence">6</field>
</record>

</data>
</odoo>
24 changes: 0 additions & 24 deletions addons/point_of_sale/data/scenarios/clothes_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,6 @@
<field name="implied_ids" eval="[(4, ref('product.group_product_variant'))]"/>
</record>

<!-- Product Category -->
<record id="product_category_clothes" model="product.category">
<field name="name">Clothes</field>
</record>

<!-- Clothes scenario config -->
<record id="pos_category_upper" model="pos.category">
<field name="name">Upper body</field>
<field name="image_128" type="base64" file="point_of_sale/static/img/clothes-icon.png" />
<field name="sequence">4</field>
</record>

<record id="pos_category_lower" model="pos.category">
<field name="name">Lower body</field>
<field name="image_128" type="base64" file="point_of_sale/static/img/lower-body-icon.png" />
<field name="sequence">5</field>
</record>

<record id="pos_category_others" model="pos.category">
<field name="name">Others</field>
<field name="image_128" type="base64" file="point_of_sale/static/img/others-icon.png" />
<field name="sequence">6</field>
</record>

<!-- Clothes products -->
<record model="product.product" id="casual_t_shirt">
<field name="name">Casual T-shirt</field>
Expand Down
22 changes: 22 additions & 0 deletions addons/point_of_sale/data/scenarios/furniture_category_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<!-- Furniture scenario pos categories -->
<record id="pos_category_miscellaneous" model="pos.category">
<field name="name">Misc</field>
<field name="image_128" type="base64" file="point_of_sale/static/img/misc_category.png" />
<field name="sequence">1</field>
</record>
<record id="pos_category_desks" model="pos.category">
<field name="name">Desks</field>
<field name="image_128" type="base64" file="point_of_sale/static/img/desk_category.png" />
<field name="sequence">2</field>
</record>
<record id="pos_category_chairs" model="pos.category">
<field name="name">Chairs</field>
<field name="image_128" type="base64" file="point_of_sale/static/img/chair_category.png" />
<field name="sequence">3</field>
</record>

</data>
</odoo>
18 changes: 0 additions & 18 deletions addons/point_of_sale/data/scenarios/furniture_data.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">

<!-- Resource: pos.category -->
<record id="pos_category_miscellaneous" model="pos.category">
<field name="name">Misc</field>
<field name="image_128" type="base64" file="point_of_sale/static/img/misc_category.png" />
<field name="sequence">1</field>
</record>
<record id="pos_category_desks" model="pos.category">
<field name="name">Desks</field>
<field name="image_128" type="base64" file="point_of_sale/static/img/desk_category.png" />
<field name="sequence">2</field>
</record>
<record id="pos_category_chairs" model="pos.category">
<field name="name">Chairs</field>
<field name="image_128" type="base64" file="point_of_sale/static/img/chair_category.png" />
<field name="sequence">3</field>
</record>

<!-- Products -->

<!-- Old -->
Expand Down
53 changes: 35 additions & 18 deletions addons/point_of_sale/models/pos_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,8 +871,8 @@ def load_demo_data(self):
loaders = self._get_demo_data_loader_methods()
for prefix, loader in loaders.items():
if xml_id.startswith(prefix):
return loader()
return loaders.get(self._get_default_demo_data_xml_id(), self._load_onboarding_furniture_demo_data)()
return loader(True)
return loaders.get(self._get_default_demo_data_xml_id(), self._load_onboarding_furniture_demo_data)(True)

def _get_demo_data_loader_methods(self):
return {
Expand All @@ -899,13 +899,13 @@ def load_onboarding_clothes_scenario(self, with_demo_data=True):
'record': config,
'noupdate': True,
}])
if with_demo_data:
config._load_onboarding_clothes_demo_data()
config._load_onboarding_clothes_demo_data(with_demo_data)
return {'config_id': config.id}

def _load_onboarding_clothes_demo_data(self):
def _load_onboarding_clothes_demo_data(self, with_demo_data=True):
self.ensure_one()
if not self.env.ref('point_of_sale.product_category_clothes', raise_if_not_found=False):
convert.convert_file(self._env_with_clean_context(), 'point_of_sale', 'data/scenarios/clothes_category_data.xml', idref=None, mode='init', noupdate=True)
if with_demo_data:
convert.convert_file(self._env_with_clean_context(), 'point_of_sale', 'data/scenarios/clothes_data.xml', idref=None, mode='init', noupdate=True)
clothes_categories = self.get_record_by_ref([
'point_of_sale.pos_category_upper',
Expand All @@ -931,13 +931,13 @@ def load_onboarding_bakery_scenario(self, with_demo_data=True):
'record': config,
'noupdate': True,
}])
if with_demo_data:
config._load_onboarding_bakery_demo_data()
config._load_onboarding_bakery_demo_data(with_demo_data)
return {'config_id': config.id}

def _load_onboarding_bakery_demo_data(self):
def _load_onboarding_bakery_demo_data(self, with_demo_data=True):
self.ensure_one()
if not self.env.ref('point_of_sale.pos_category_breads', raise_if_not_found=False):
convert.convert_file(self._env_with_clean_context(), 'point_of_sale', 'data/scenarios/bakery_category_data.xml', idref=None, mode='init', noupdate=True)
if with_demo_data:
convert.convert_file(self._env_with_clean_context(), 'point_of_sale', 'data/scenarios/bakery_data.xml', idref=None, mode='init', noupdate=True)

bakery_categories = self.get_record_by_ref([
Expand Down Expand Up @@ -965,17 +965,16 @@ def load_onboarding_furniture_scenario(self, with_demo_data=True):
'record': config,
'noupdate': True,
}])
if with_demo_data:
config._load_onboarding_furniture_demo_data()
if self.env.company.id == self.env.ref('base.main_company').id:
existing_session = self.env.ref('point_of_sale.pos_closed_session_2', raise_if_not_found=False)
if not existing_session:
convert.convert_file(self._env_with_clean_context(), 'point_of_sale', 'data/orders_demo.xml', idref=None, mode='init', noupdate=True)
config._load_onboarding_furniture_demo_data(with_demo_data)
existing_session = self.env.ref('point_of_sale.pos_closed_session_2', raise_if_not_found=False)
if with_demo_data and self.env.company.id == self.env.ref('base.main_company').id and not existing_session:
convert.convert_file(self._env_with_clean_context(), 'point_of_sale', 'data/orders_demo.xml', idref=None, mode='init', noupdate=True)
return {'config_id': config.id}

def _load_onboarding_furniture_demo_data(self):
def _load_onboarding_furniture_demo_data(self, with_demo_data=False):
self.ensure_one()
if not self.env.ref('point_of_sale.pos_category_miscellaneous', raise_if_not_found=False):
convert.convert_file(self._env_with_clean_context(), 'point_of_sale', 'data/scenarios/furniture_category_data.xml', idref=None, mode='init', noupdate=True)
if with_demo_data:
product_module = self.env['ir.module.module'].search([('name', '=', 'product')])
if not product_module.demo:
convert.convert_file(self._env_with_clean_context(), 'product', 'data/product_category_demo.xml', idref=None, mode='init', noupdate=True)
Expand All @@ -992,6 +991,24 @@ def _load_onboarding_furniture_demo_data(self):
self.limit_categories = True
self.iface_available_categ_ids = furniture_categories

@api.model
def load_onboarding_retail_scenario(self, with_demo_data=False):
journal, payment_methods_ids = self._create_journal_and_payment_methods(
cash_journal_vals={'name': _("Cash %s", self.env.company.name), 'show_on_dashboard': False},
)
config = self.env['pos.config'].create([{
'name': self.env.company.name,
'company_id': self.env.company.id,
'journal_id': journal.id,
'payment_method_ids': payment_methods_ids
}])
self.env['ir.model.data']._update_xmlids([{
'xml_id': self._get_suffixed_ref_name('point_of_sale.pos_config_retail'),
'record': config,
'noupdate': True,
}])
return {'config_id': config.id}

def _get_suffixed_ref_name(self, ref_name):
"""Suffix the given ref_name with the id of the current company if it's not the main company."""
main_company = self.env.ref('base.main_company', raise_if_not_found=False)
Expand Down
3 changes: 2 additions & 1 deletion addons/point_of_sale/models/pos_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,8 @@ def close_session_from_ui(self, bank_payment_method_diff_pairs=None):
'redirect': True
}

self.post_close_register_message()
if self.env.user.email:
self.post_close_register_message()
self.config_id._notify(('CLOSING_SESSION', {'login_number': self.env.context.get('login_number', False), 'session_id': self.id}))
return {'successful': True}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class CategorySelector extends Component {
const allParents = selected.concat(this.pos.selectedCategory?.allParents || []).reverse();
return this.getCategoriesList(rootCategories, allParents, 0)
.flat(Infinity)
.filter((c) => c.hasProductsToShow)
.map(this.getChildCategoriesInfo, this);
}

Expand Down
4 changes: 4 additions & 0 deletions addons/point_of_sale/static/src/app/models/pos_category.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export class PosCategory extends Base {
// Remove duplicates since owl doesn't like them.
return Array.from(new Set(products));
}

get hasProductsToShow() {
return this.associatedProducts.length > 0;
}
}

registry.category("pos_available_models").add(PosCategory.pythonModel, PosCategory);
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ export class PosKanbanRenderer extends KanbanRenderer {
async ({ functionName, isRestaurant }) =>
await this.callWithViewUpdate(async () => {
let isInstalledWithDemo = false;
// The demo data is not loaded for the first config
const withDemoData = this.posState.has_pos_config;
if (isRestaurant && !this.posState.is_restaurant_installed) {
const result = await this.orm.call("pos.config", "install_pos_restaurant");
isInstalledWithDemo = result.installed_with_demo;
Expand All @@ -55,12 +53,9 @@ export class PosKanbanRenderer extends KanbanRenderer {
!isInstalledWithDemo ||
(isInstalledWithDemo && !this.posState.is_main_company)
) {
const result = await this.orm.call("pos.config", functionName, [
withDemoData,
]);
if (!this.posState.has_pos_config) {
return result;
}
// load onboarding scenario without demo data
const result = await this.orm.call("pos.config", functionName, [false]);
return result;
}
})
);
Expand All @@ -73,12 +68,6 @@ export class PosKanbanRenderer extends KanbanRenderer {
if (this.loadScenario.status == "error") {
throw this.loadScenario.result;
}
if (this.loadScenario.result?.config_id) {
// Open the POS
const { config_id } = this.loadScenario.result;
const action = await this.orm.call("pos.config", "open_ui", [[config_id]]);
await this.action.doAction(action);
}
}

checkDisplayedResult() {
Expand Down Expand Up @@ -151,8 +140,14 @@ export class PosKanbanRenderer extends KanbanRenderer {
];
}

createNewProducts() {
window.open("/odoo/action-point_of_sale.action_client_product_menu", "_self");
get retailScenario() {
return {
name: _t("Retail"),
isRestaurant: false,
description: _t("Any shop"),
functionName: "load_onboarding_retail_scenario",
iconFile: this.isDarkTheme ? "retail-icon-dark.png" : "retail-icon.png",
};
}

showTopBorder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<t t-call="web.KanbanRenderer" />
<div class="position-relative container" t-att-class="{ 'border-top mt-2': showTopBorder() }" t-if="this.posState.show_predefined_scenarios">
<div class="flex-grow-1 text-center" t-att-class="{ 'disable-buttons': !posState.has_chart_template || loadScenario.status === 'loading' }">
<p class="h1 text-primary mt-4" t-if="!posState.has_pos_config">Want to try with sample products?</p>
<p class="h1 text-primary mt-4" t-if="!posState.has_pos_config">Choose your store</p>
<p t-if="!posState.has_chart_template" class="h2 m-3">
Please <a href="#" class="btn-link o_form_uri" role="button" t-on-click="() => action.doAction('account.action_account_config')">install a chart of accounts</a> to activate the buttons.
</p>
<p t-else="" class="h2 m-3">Choose your store</p>
<br />
<div t-attf-class="d-flex {{posState.is_restaurant_installed ? 'flex-column' : 'flex-column-reverse'}}">
<div class="shop-scenarios row p-3">
<t t-foreach="shopScenarios" t-as="item" t-key="item_index">
Expand All @@ -26,28 +26,10 @@
<t t-foreach="restaurantScenarios" t-as="item" t-key="item_index">
<t t-call="point_of_sale.ScenarioCard" />
</t>
<t t-set="item" t-value="retailScenario" />
<t t-call="point_of_sale.ScenarioCard" />
</div>
</div>
<div class="text-center my-4">
<div class="row">
<div class="col">
<hr class="my-2"/>
</div>
<div class="col-auto">
<span class="px-3 h4">or</span>
</div>
<div class="col">
<hr class="my-2"/>
</div>
</div>
</div>
<p class="text-large">
<a role="button" class="btn btn-lg btn-secondary fw-bolder"
t-on-click="createNewProducts"
t-att-class="{ 'disabled': !posState.has_chart_template || loadScenario.status === 'loading' }">
Create my own products
</a>
</p>
</div>
</div>
</div>
Expand Down
Loading