Initial commit: Sale packages

This commit is contained in:
Ernad Husremovic 2025-08-29 15:20:49 +02:00
commit 14e3d26998
6469 changed files with 2479670 additions and 0 deletions

View file

@ -0,0 +1,49 @@
# pos_sale_loyalty
This module correct some behaviors when both module are installed.
## Installation
```bash
pip install odoo-bringout-oca-ocb-pos_sale_loyalty
```
## Dependencies
This addon depends on:
- pos_sale
- pos_loyalty
## Manifest Information
- **Name**: pos_sale_loyalty
- **Version**: 1.0
- **Category**: Hidden
- **License**: LGPL-3
- **Installable**: True
## Source
Based on [OCA/OCB](https://github.com/OCA/OCB) branch 16.0, addon `pos_sale_loyalty`.
## License
This package maintains the original LGPL-3 license from the upstream Odoo project.
## Documentation
- Overview: doc/OVERVIEW.md
- Architecture: doc/ARCHITECTURE.md
- Models: doc/MODELS.md
- Controllers: doc/CONTROLLERS.md
- Wizards: doc/WIZARDS.md
- Reports: doc/REPORTS.md
- Security: doc/SECURITY.md
- Install: doc/INSTALL.md
- Usage: doc/USAGE.md
- Configuration: doc/CONFIGURATION.md
- Dependencies: doc/DEPENDENCIES.md
- Troubleshooting: doc/TROUBLESHOOTING.md
- FAQ: doc/FAQ.md

View file

@ -0,0 +1,32 @@
# Architecture
```mermaid
flowchart TD
U[Users] -->|HTTP| V[Views and QWeb Templates]
V --> C[Controllers]
V --> W[Wizards Transient Models]
C --> M[Models and ORM]
W --> M
M --> R[Reports]
DX[Data XML] --> M
S[Security ACLs and Groups] -. enforces .-> M
subgraph Pos_sale_loyalty Module - pos_sale_loyalty
direction LR
M:::layer
W:::layer
C:::layer
V:::layer
R:::layer
S:::layer
DX:::layer
end
classDef layer fill:#eef8ff,stroke:#6ea8fe,stroke-width:1px
```
Notes
- Views include tree/form/kanban templates and report templates.
- Controllers provide website/portal routes when present.
- Wizards are UI flows implemented with `models.TransientModel`.
- Data XML loads data/demo records; Security defines groups and access.

View file

@ -0,0 +1,3 @@
# Configuration
Refer to Odoo settings for pos_sale_loyalty. Configure related models, access rights, and options as needed.

View file

@ -0,0 +1,3 @@
# Controllers
This module does not define custom HTTP controllers.

View file

@ -0,0 +1,6 @@
# Dependencies
This addon depends on:
- [pos_sale](../../odoo-bringout-oca-ocb-pos_sale)
- [pos_loyalty](../../odoo-bringout-oca-ocb-pos_loyalty)

View file

@ -0,0 +1,4 @@
# FAQ
- Q: Which Odoo version? A: 16.0 (OCA/OCB packaged).
- Q: How to enable? A: Start server with --addon pos_sale_loyalty or install in UI.

View file

@ -0,0 +1,7 @@
# Install
```bash
pip install odoo-bringout-oca-ocb-pos_sale_loyalty"
# or
uv pip install odoo-bringout-oca-ocb-pos_sale_loyalty"
```

View file

@ -0,0 +1,12 @@
# Models
Detected core models and extensions in pos_sale_loyalty.
```mermaid
classDiagram
class sale_order_line
```
Notes
- Classes show model technical names; fields omitted for brevity.
- Items listed under _inherit are extensions of existing models.

View file

@ -0,0 +1,6 @@
# Overview
Packaged Odoo addon: pos_sale_loyalty. Provides features documented in upstream Odoo 16 under this addon.
- Source: OCA/OCB 16.0, addon pos_sale_loyalty
- License: LGPL-3

View file

@ -0,0 +1,3 @@
# Reports
This module does not define custom reports.

View file

@ -0,0 +1,8 @@
# Security
This module does not define custom security rules or access controls beyond Odoo defaults.
Default Odoo security applies:
- Base user access through standard groups
- Model access inherited from dependencies
- No custom row-level security rules

View file

@ -0,0 +1,5 @@
# Troubleshooting
- Ensure Python and Odoo environment matches repo guidance.
- Check database connectivity and logs if startup fails.
- Validate that dependent addons listed in DEPENDENCIES.md are installed.

View file

@ -0,0 +1,7 @@
# Usage
Start Odoo including this addon (from repo root):
```bash
python3 scripts/nix_odoo_web_server.py --db-name mydb --addon pos_sale_loyalty
```

View file

@ -0,0 +1,3 @@
# Wizards
This module does not include UI wizards.

View file

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models

View file

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'pos_sale_loyalty',
'version': '1.0',
'category': 'Hidden',
'sequence': 6,
'summary': 'Link module between pos_sale and pos_loyalty',
'description': """
This module correct some behaviors when both module are installed.
""",
'depends': ['pos_sale', 'pos_loyalty'],
'installable': True,
'auto_install': True,
'assets': {
'point_of_sale.assets': [
'pos_sale_loyalty/static/src/js/**/*.js',
],
'web.assets_tests': [
'pos_sale_loyalty/static/src/tours/**/*',
],
},
'license': 'LGPL-3',
}

View file

@ -0,0 +1,21 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_sale_loyalty
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-02-06 13:31+0000\n"
"PO-Revision-Date: 2024-02-06 13:31+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: pos_sale_loyalty
#: model:ir.model,name:pos_sale_loyalty.model_sale_order_line
msgid "Sales Order Line"
msgstr "Stavka prodajne narudžbe"

View file

@ -0,0 +1,21 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_sale_loyalty
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-02-06 13:31+0000\n"
"PO-Revision-Date: 2024-02-06 13:31+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: pos_sale_loyalty
#: model:ir.model,name:pos_sale_loyalty.model_sale_order_line
msgid "Sales Order Line"
msgstr ""

View file

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import sale_order

View file

@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'
def _get_sale_order_fields(self):
field_names = super()._get_sale_order_fields()
field_names.append('reward_id')
return field_names

View file

@ -0,0 +1,26 @@
/** @odoo-module alias=pos_sale_loyalty.models **/
import { Orderline } from 'point_of_sale.models';
import Registries from 'point_of_sale.Registries';
export const PosSaleLoyaltyOrderline = (Orderline) => class PosSaleLoyaltyOrderline extends Orderline {
//@override
ignoreLoyaltyPoints(args) {
if (this.sale_order_origin_id) {
return true;
}
return super.ignoreLoyaltyPoints(args);
}
//@override
setQuantityFromSOL(saleOrderLine) {
// we need to consider reward product such as discount in a quotation
if (saleOrderLine.reward_id) {
this.set_quantity(saleOrderLine.product_uom_qty);
} else {
super.setQuantityFromSOL(...arguments);
}
}
};
Registries.Model.extend(Orderline, PosSaleLoyaltyOrderline);

View file

@ -0,0 +1,21 @@
/** @odoo-module **/
import { PaymentScreen } from 'point_of_sale.tour.PaymentScreenTourMethods';
import { ProductScreen } from 'pos_sale.tour.ProductScreenTourMethods';
import { ReceiptScreen } from 'point_of_sale.tour.ReceiptScreenTourMethods';
import { getSteps, startSteps } from 'point_of_sale.tour.utils';
import Tour from 'web_tour.tour';
// First tour should not get any automatic rewards
startSteps();
ProductScreen.do.confirmOpeningPopup();
ProductScreen.do.clickQuotationButton();
ProductScreen.do.selectFirstOrder();
ProductScreen.do.clickDisplayedProduct('Desk Pad');
ProductScreen.do.clickPayButton();
PaymentScreen.do.clickPaymentMethod('Bank');
PaymentScreen.do.clickValidate();
ReceiptScreen.check.isShown();
Tour.register('PosSaleLoyaltyTour1', { test: true, url: '/pos/web' }, getSteps());

View file

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import test_pos_sale_loyalty

View file

@ -0,0 +1,45 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.pos_loyalty.tests.test_frontend import TestPoSLoyaltyCommon
from odoo.tests import tagged
@tagged("post_install", "-at_install")
class TestPoSSaleLoyalty(TestPoSLoyaltyCommon):
def test_pos_sale_loyalty_1(self):
"""Test that only one loyalty card is created when settling an unconfirmed order."""
self.env['loyalty.program'].search([]).write({'active': False})
self.env['loyalty.program'].create({
'name': 'Test Loyalty Program',
'program_type': 'loyalty',
'trigger': 'auto',
'applies_on': 'both',
'rule_ids': [
(0, 0, {
'reward_point_mode': 'money',
'minimum_amount': 1,
'reward_point_amount': 1,
}),
],
'reward_ids': [
(0, 0, {
'reward_type': 'discount',
'discount': 1,
'required_points': 1000,
'discount_mode': 'percent',
'discount_applicability': 'order',
}),
],
})
self.env['sale.order'].create({
'partner_id': self.partner_a.id,
'order_line': [(0, 0, {
'product_id': self.desk_organizer.id,
'product_uom_qty': 1,
'price_unit': 100,
})]
})
self.main_pos_config.open_ui()
self.start_tour("/pos/web?config_id=%d" % self.main_pos_config.id, "PosSaleLoyaltyTour1", login="accountman")
self.assertEqual(self.env['loyalty.card'].search_count([('partner_id', '=', self.partner_a.id)]), 1)

View file

@ -0,0 +1,43 @@
[project]
name = "odoo-bringout-oca-ocb-pos_sale_loyalty"
version = "16.0.0"
description = "pos_sale_loyalty - Link module between pos_sale and pos_loyalty"
authors = [
{ name = "Ernad Husremovic", email = "hernad@bring.out.ba" }
]
dependencies = [
"odoo-bringout-oca-ocb-pos_sale>=16.0.0",
"odoo-bringout-oca-ocb-pos_loyalty>=16.0.0",
"requests>=2.25.1"
]
readme = "README.md"
requires-python = ">= 3.11"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Office/Business",
]
[project.urls]
homepage = "https://github.com/bringout/0"
repository = "https://github.com/bringout/0"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.metadata]
allow-direct-references = true
[tool.hatch.build.targets.wheel]
packages = ["pos_sale_loyalty"]
[tool.rye]
managed = true
dev-dependencies = [
"pytest>=8.4.1",
]