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,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)