Начальное наполнение
This commit is contained in:
parent
512ebbccd8
commit
aee393c859
4
__init__.py
Normal file
4
__init__.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
from . import report
|
18
__manifest__.py
Normal file
18
__manifest__.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
'name': 'POS - Sale Margin',
|
||||||
|
'version': '1.1',
|
||||||
|
'category': 'Hidden',
|
||||||
|
'summary': 'Link module between Point of Sale and Sales Margin',
|
||||||
|
'description': """
|
||||||
|
|
||||||
|
This module adds enable you to view the margin of your Point of Sale orders in the Sales Margin report.
|
||||||
|
""",
|
||||||
|
'depends': ['pos_sale', 'sale_margin'],
|
||||||
|
'installable': True,
|
||||||
|
'auto_install': True,
|
||||||
|
'license': 'LGPL-3',
|
||||||
|
}
|
21
i18n/pos_sale_margin.pot
Normal file
21
i18n/pos_sale_margin.pot
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Translation of Odoo Server.
|
||||||
|
# This file contains the translation of the following modules:
|
||||||
|
# * pos_sale_margin
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Odoo Server 17.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2023-10-26 21:55+0000\n"
|
||||||
|
"PO-Revision-Date: 2023-10-26 21:55+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_margin
|
||||||
|
#: model:ir.model,name:pos_sale_margin.model_sale_report
|
||||||
|
msgid "Sales Analysis Report"
|
||||||
|
msgstr ""
|
23
i18n/ru.po
Normal file
23
i18n/ru.po
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Translation of Odoo Server.
|
||||||
|
# This file contains the translation of the following modules:
|
||||||
|
# * pos_sale_margin
|
||||||
|
#
|
||||||
|
# Translators:
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Odoo Server 17.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2023-10-26 21:55+0000\n"
|
||||||
|
"PO-Revision-Date: 2024-01-30 15:14+0400\n"
|
||||||
|
"Last-Translator: \n"
|
||||||
|
"Language-Team: Russian (https://app.transifex.com/odoo/teams/41243/ru/)\n"
|
||||||
|
"Language: ru\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: \n"
|
||||||
|
"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n"
|
||||||
|
|
||||||
|
#. module: pos_sale_margin
|
||||||
|
#: model:ir.model,name:pos_sale_margin.model_sale_report
|
||||||
|
msgid "Sales Analysis Report"
|
||||||
|
msgstr "Отчет об анализе продаж"
|
4
report/__init__.py
Normal file
4
report/__init__.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
from . import sale_report
|
13
report/sale_report.py
Normal file
13
report/sale_report.py
Normal 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 SaleReport(models.Model):
|
||||||
|
_inherit = "sale.report"
|
||||||
|
|
||||||
|
def _fill_pos_fields(self, additional_fields):
|
||||||
|
values = super()._fill_pos_fields(additional_fields)
|
||||||
|
values['margin'] = 'SUM(l.price_subtotal - COALESCE(l.total_cost,0) / CASE COALESCE(pos.currency_rate, 0) WHEN 0 THEN 1.0 ELSE pos.currency_rate END)'
|
||||||
|
return values
|
4
tests/__init__.py
Normal file
4
tests/__init__.py
Normal 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_margin_report
|
43
tests/test_pos_sale_margin_report.py
Normal file
43
tests/test_pos_sale_margin_report.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||||
|
import odoo
|
||||||
|
|
||||||
|
from odoo.addons.point_of_sale.tests.common import TestPoSCommon
|
||||||
|
|
||||||
|
|
||||||
|
@odoo.tests.tagged('post_install', '-at_install')
|
||||||
|
class TestPoSSaleMarginReport(TestPoSCommon):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestPoSSaleMarginReport, self).setUp()
|
||||||
|
self.config = self.basic_config
|
||||||
|
|
||||||
|
def test_pos_sale_margin_report(self):
|
||||||
|
|
||||||
|
product1 = self.create_product('Product 1', self.categ_basic, 150, standard_price=50)
|
||||||
|
|
||||||
|
self.open_new_session()
|
||||||
|
session = self.pos_session
|
||||||
|
|
||||||
|
self.env['pos.order'].create({
|
||||||
|
'session_id': session.id,
|
||||||
|
'lines': [(0, 0, {
|
||||||
|
'name': "OL/0001",
|
||||||
|
'product_id': product1.id,
|
||||||
|
'price_unit': 450,
|
||||||
|
'discount': 5.0,
|
||||||
|
'qty': 1.0,
|
||||||
|
'price_subtotal': 150,
|
||||||
|
'price_subtotal_incl': 150,
|
||||||
|
'total_cost': 50,
|
||||||
|
}),],
|
||||||
|
'amount_total': 150.0,
|
||||||
|
'amount_tax': 0.0,
|
||||||
|
'amount_paid': 0.0,
|
||||||
|
'amount_return': 0.0,
|
||||||
|
})
|
||||||
|
|
||||||
|
# PoS Orders have negative IDs to avoid conflict, so reports[0] will correspond to the newest order
|
||||||
|
reports = self.env['sale.report'].sudo().search([('product_id', '=', product1.id)], order='id')
|
||||||
|
|
||||||
|
self.assertEqual(reports[0].margin, 100)
|
Loading…
x
Reference in New Issue
Block a user