From 743b2007e27a83d36b12b0373ac471a6923c1eb5 Mon Sep 17 00:00:00 2001 From: Rodia Date: Fri, 6 Jun 2025 21:32:38 -0500 Subject: [PATCH] revert b51c12eeb9be19f8feb7af024cea89bc5876e6c9 revert update 7.6 --- production.py | 8 +- sale.xml | 10 +- tests/scenario_report_pizza.rst | 258 ++++++++++++++++++++++++++++++ tests/scenario_sale_fast_food.rst | 213 ++++++++++++++++++++++++ tryton.cfg | 2 +- 5 files changed, 480 insertions(+), 11 deletions(-) create mode 100644 tests/scenario_report_pizza.rst create mode 100644 tests/scenario_sale_fast_food.rst diff --git a/production.py b/production.py index a8ee65d..01ce45e 100644 --- a/production.py +++ b/production.py @@ -1,8 +1,8 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. -# from decimal import Decimal -from trytond.pool import PoolMeta -# from trytond.model import fields +from decimal import Decimal +from trytond.pool import Pool, PoolMeta +from trytond.model import fields BOM_CHANGES = ['bom', 'product', 'quantity', 'uom', 'warehouse', 'location', @@ -13,7 +13,6 @@ class Production(metaclass=PoolMeta): "Production" __name__ = 'production' - """ @fields.depends( 'bom', 'product', 'uom', 'quantity', 'company', 'inputs', 'outputs', methods=['_explode_move_values']) @@ -56,4 +55,3 @@ class Production(metaclass=PoolMeta): move.unit_price = Decimal(0) outputs.append(move) self.outputs = outputs - """ diff --git a/sale.xml b/sale.xml index 2b5d4c8..4700891 100644 --- a/sale.xml +++ b/sale.xml @@ -21,27 +21,27 @@ add_pizza Add Pizza - sale.sale + kitchen Kitchen - sale.sale + bar Bar - sale.sale + print_bill Bill - sale.sale + impreso Impreso - sale.sale + Customer Order diff --git a/tests/scenario_report_pizza.rst b/tests/scenario_report_pizza.rst new file mode 100644 index 0000000..5b81c8d --- /dev/null +++ b/tests/scenario_report_pizza.rst @@ -0,0 +1,258 @@ +============================= +Sale Line Delete Log Scenario +============================= + +Imports:: + >>> from decimal import Decimal + >>> from proteus import Model, Wizard + >>> from trytond.tests.tools import activate_modules + >>> from trytond.modules.company.tests.tools import create_company, get_company + >>> from trytond.modules.account.tests.tools import ( + ... create_chart, create_fiscalyear, create_tax, get_accounts) + >>> from trytond.modules.account_invoice.tests.tools import ( + ... create_payment_term, set_fiscalyear_invoice_sequences) + >>> import datetime as dt + >>> today = dt.date.today() + >>> from trytond.tests.tools import set_user + >>> from trytond.modules.sale_shop.tests.tools import create_shop + >>> from trytond.modules.sale_line_delete_log.sale import SaleLineDeleted + + +Activate modules:: + + >>> config = activate_modules('sale_fast_food') + + + >>> User = Model.get('res.user') + >>> Party = Model.get('party.party') + >>> Employee = Model.get('company.employee') + >>> Journal = Model.get('account.journal') + >>> PaymentMethod = Model.get('account.invoice.payment.method') + >>> Party = Model.get('party.party') + >>> ProductUom = Model.get('product.uom') + >>> ProductTemplate = Model.get('product.template') + >>> Sale = Model.get('sale.sale') + >>> SaleLine = Model.get('sale.line') + +Create company:: + + >>> _ = create_company() + >>> company = get_company() + +Set employee:: + + >>> employee_party = Party(name="Employee") + >>> employee_party.save() + >>> employee = Employee(party=employee_party) + >>> employee.save() + >>> user = User(config.user) + >>> user.employees.append(employee) + >>> user.employee = employee + >>> user.save() + >>> set_user(user.id) + +Create fiscal year:: + + >>> fiscalyear = set_fiscalyear_invoice_sequences(create_fiscalyear(company, today)) + >>> fiscalyear.click('create_period') + +Create chart of accounts:: + + >>> _ = create_chart(company) + >>> accounts = get_accounts(company) + >>> revenue = accounts['revenue'] + >>> expense = accounts['expense'] + >>> cash = accounts['cash'] + + >>> cash_journal, = Journal.find([('type', '=', 'cash')]) + >>> cash_journal.save() + >>> payment_method = PaymentMethod() + >>> payment_method.name = 'Cash' + >>> payment_method.journal = cash_journal + >>> payment_method.credit_account = cash + >>> payment_method.debit_account = cash + >>> payment_method.save() + +Create tax:: + + >>> tax = create_tax(Decimal('.10')) + >>> tax.save() + +Create parties:: + + >>> supplier = Party(name='Supplier') + >>> supplier.save() + >>> customer = Party(name='Customer') + >>> customer.save() + +Create account categories:: + + >>> ProductCategory = Model.get('product.category') + >>> account_category = ProductCategory(name="Account Category") + >>> account_category.accounting = True + >>> account_category.account_expense = expense + >>> account_category.account_revenue = revenue + >>> account_category.save() + + >>> account_category_tax, = account_category.duplicate() + >>> account_category_tax.customer_taxes.append(tax) + >>> account_category_tax.save() + +Create product:: + + >>> unit, = ProductUom.find([('name', '=', 'Unit')]) + + >>> template = ProductTemplate() + >>> template.name = 'product' + >>> template.default_uom = unit + >>> template.type = 'goods' + >>> template.salable = True + >>> template.pizza = True + >>> template.list_price = Decimal('10') + >>> template.account_category = account_category_tax + >>> template.save() + >>> product_pizza, = template.products + + >>> template = ProductTemplate() + >>> template.name = 'service' + >>> template.default_uom = unit + >>> template.type = 'service' + >>> template.pizza = False + >>> template.salable = True + >>> template.list_price = Decimal('30') + >>> template.account_category = account_category + >>> template.save() + >>> service, = template.products + +Create payment term:: + + >>> payment_term = create_payment_term() + >>> payment_term.save() + +Create product price list:: + + >>> ProductPriceList = Model.get('product.price_list') + >>> product_price_list = ProductPriceList() + >>> product_price_list.name = 'Price List' + >>> product_price_list.company = company + >>> product_price_list.save() + +Create an Inventory:: + + >>> Inventory = Model.get('stock.inventory') + >>> Location = Model.get('stock.location') + >>> storage, = Location.find([ + ... ('code', '=', 'STO'), + ... ]) + >>> inventory = Inventory() + >>> inventory.location = storage + >>> inventory_line = inventory.lines.new(product=product_pizza) + >>> inventory_line.quantity = 100.0 + >>> inventory_line.expected_quantity = 0.0 + >>> inventory.click('confirm') + >>> inventory.state + 'done' + +Create Sale Shop:: + + >>> shop = create_shop(payment_term, product_price_list) + >>> shop.save() + >>> Device = Model.get('sale.device') + >>> device = Device() + >>> device.name = "SE Device" + >>> device.shop = shop + >>> device.save() + +Save Sale Shop User:: + + >>> User = Model.get('res.user') + >>> user, = User.find([]) + >>> user.shops.append(shop) + >>> user.shop = shop + >>> user.save() + >>> set_user(user) + + +Crear Una Zona de Venta:: + >>> Zone = Model.get('sale.zone') + >>> zone = Zone() + >>> zone.name = "Main" + >>> zone.save() + >>> zone1 = Zone() + >>> zone1.name = "SE" + >>> zone1.shop = shop + >>> zone1.device = device + >>> zone1.parent = zone + >>> zone1.save() + >>> table1 = zone1.tables.new() + >>> table1.name = "CH1" + >>> table1.save() + >>> table2 = zone1.tables.new() + >>> table2.name = "CH1" + >>> table2.save() + +Sale 5 products:: + + >>> sale = Sale() + >>> sale.party = customer + >>> sale.payment_term = payment_term + >>> sale.zone = zone1 + >>> sale.table = table1 + >>> sale.invoice_method = 'order' + + >>> sale_line = SaleLine() + >>> sale.lines.append(sale_line) + + >>> sale_line.product = product_pizza + >>> sale_line.quantity = 2.0 + >>> sale_line.impreso = True + + >>> sale_line = SaleLine() + >>> sale.lines.append(sale_line) + >>> sale_line.product = product_pizza + >>> sale_line.quantity = 3.0 + + >>> sale_line = SaleLine() + >>> sale.lines.append(sale_line) + >>> sale_line.product = service + >>> sale_line.quantity = 5.0 + + >>> sale.save() + >>> len(sale.lines) + 3 + +Sale Fast Food Pizzas Sell by Product:: + >>> ReportSellPizzas = Model.get('sale_fast_food.reporting.product') + >>> reports = ReportSellPizzas.find([]) + + >>> expected_report = { + ... (product_pizza, 5.0) + ... } + + >>> actual_report = {(r.product_pizza, r.quantity) for r in reports} + >>> assert expected_report == actual_report, f"\n Expect: {expected_report} \n Actual: {actual_report}" + +Sale Fast Food Sales by User:: + >>> User = Model.get('res.user') + >>> user = User(config.user) + + >>> ReportSalesByUser = Model.get('sale_fast_food.reporting.by_user') + >>> reports = ReportSalesByUser.find([]) + + >>> expected_report = { + ... (user, 1) + ... } + + >>> actual_report = {(r.user, r.completed_sales) for r in reports} + >>> assert expected_report == actual_report, f"\n Expect: {expected_report} \n Actual: {actual_report}" + +Sale Fast Food Sales by Zone:: + >>> ReportSalesByZone = Model.get('sale_fast_food.reporting.zone') + >>> reports = ReportSalesByZone.find([]) + + >>> expected_report = { + ... (table1, zone) + ... } + + >>> actual_report = {(r.table, r.zone) for r in reports} + >>> assert expected_report == actual_report, f"\n Expect: {expected_report} \n Actual: {actual_report}" diff --git a/tests/scenario_sale_fast_food.rst b/tests/scenario_sale_fast_food.rst new file mode 100644 index 0000000..3e7cda3 --- /dev/null +++ b/tests/scenario_sale_fast_food.rst @@ -0,0 +1,213 @@ +============================= +Sale Line Delete Log Scenario +============================= + +Imports:: + >>> from decimal import Decimal + >>> from proteus import Model, Wizard + >>> from trytond.tests.tools import activate_modules + >>> from trytond.modules.company.tests.tools import create_company, get_company + >>> from trytond.modules.account.tests.tools import ( + ... create_chart, create_fiscalyear, create_tax, get_accounts) + >>> from trytond.modules.account_invoice.tests.tools import ( + ... create_payment_term, set_fiscalyear_invoice_sequences) + >>> import datetime as dt + >>> today = dt.date.today() + >>> from trytond.tests.tools import set_user + >>> from trytond.modules.sale_shop.tests.tools import create_shop + >>> from trytond.modules.sale_line_delete_log.sale import SaleLineDeleted + +Activate modules:: + + >>> config = activate_modules('sale_fast_food') + +Initial data:: + + >>> User = Model.get('res.user') + >>> Party = Model.get('party.party') + >>> Employee = Model.get('company.employee') + >>> Journal = Model.get('account.journal') + >>> PaymentMethod = Model.get('account.invoice.payment.method') + >>> Party = Model.get('party.party') + >>> ProductUom = Model.get('product.uom') + >>> ProductTemplate = Model.get('product.template') + >>> Sale = Model.get('sale.sale') + >>> SaleLine = Model.get('sale.line') + +Create company:: + + >>> _ = create_company() + >>> company = get_company() + +Set employee:: + + >>> employee_party = Party(name="Employee") + >>> employee_party.save() + >>> employee = Employee(party=employee_party) + >>> employee.save() + >>> user = User(config.user) + >>> user.employees.append(employee) + >>> user.employee = employee + >>> user.save() + >>> set_user(user.id) + +Create fiscal year:: + + >>> fiscalyear = set_fiscalyear_invoice_sequences(create_fiscalyear(company, today)) + >>> fiscalyear.click('create_period') + +Create chart of accounts:: + + >>> _ = create_chart(company) + >>> accounts = get_accounts(company) + >>> revenue = accounts['revenue'] + >>> expense = accounts['expense'] + >>> cash = accounts['cash'] + + >>> cash_journal, = Journal.find([('type', '=', 'cash')]) + >>> cash_journal.save() + >>> payment_method = PaymentMethod() + >>> payment_method.name = 'Cash' + >>> payment_method.journal = cash_journal + >>> payment_method.credit_account = cash + >>> payment_method.debit_account = cash + >>> payment_method.save() + +Create tax:: + + >>> tax = create_tax(Decimal('.10')) + >>> tax.save() + +Create parties:: + + >>> supplier = Party(name='Supplier') + >>> supplier.save() + >>> customer = Party(name='Customer') + >>> customer.save() + +Create account categories:: + + >>> ProductCategory = Model.get('product.category') + >>> account_category = ProductCategory(name="Account Category") + >>> account_category.accounting = True + >>> account_category.account_expense = expense + >>> account_category.account_revenue = revenue + >>> account_category.save() + + >>> account_category_tax, = account_category.duplicate() + >>> account_category_tax.customer_taxes.append(tax) + >>> account_category_tax.save() + +Create product:: + + >>> unit, = ProductUom.find([('name', '=', 'Unit')]) + + >>> template = ProductTemplate() + >>> template.name = 'product' + >>> template.default_uom = unit + >>> template.type = 'goods' + >>> template.salable = True + >>> template.pizza = True + >>> template.list_price = Decimal('10') + >>> template.account_category = account_category_tax + >>> template.save() + >>> product, = template.products + + >>> template = ProductTemplate() + >>> template.name = 'service' + >>> template.default_uom = unit + >>> template.type = 'service' + >>> template.salable = True + >>> template.list_price = Decimal('30') + >>> template.account_category = account_category + >>> template.save() + >>> service, = template.products + +Create payment term:: + + >>> payment_term = create_payment_term() + >>> payment_term.save() + +Create product price list:: + + >>> ProductPriceList = Model.get('product.price_list') + >>> product_price_list = ProductPriceList() + >>> product_price_list.name = 'Price List' + >>> product_price_list.company = company + >>> product_price_list.save() + +Create an Inventory:: + + >>> Inventory = Model.get('stock.inventory') + >>> Location = Model.get('stock.location') + >>> storage, = Location.find([ + ... ('code', '=', 'STO'), + ... ]) + >>> inventory = Inventory() + >>> inventory.location = storage + >>> inventory_line = inventory.lines.new(product=product) + >>> inventory_line.quantity = 100.0 + >>> inventory_line.expected_quantity = 0.0 + >>> inventory.click('confirm') + >>> inventory.state + 'done' + +Create Sale Shop:: + + >>> shop = create_shop(payment_term, product_price_list) + >>> shop.save() + +Save Sale Shop User:: + + >>> User = Model.get('res.user') + >>> user, = User.find([]) + >>> user.shops.append(shop) + >>> user.shop = shop + >>> user.save() + >>> set_user(user) + +Sale 5 products:: + + >>> sale = Sale() + >>> sale.party = customer + >>> sale.payment_term = payment_term + >>> sale.invoice_method = 'order' + + >>> sale_line = SaleLine() + >>> sale.lines.append(sale_line) + >>> sale_line.product = product + >>> sale_line.quantity = 2.0 + >>> sale_line.impreso = True + + >>> sale_line = SaleLine() + >>> sale.lines.append(sale_line) + >>> sale_line.type = 'comment' + >>> sale_line.description = 'Comment' + + >>> sale_line = SaleLine() + >>> sale.lines.append(sale_line) + >>> sale_line.product = product + >>> sale_line.quantity = 3.0 + >>> sale.save() + >>> len(sale.lines) + 3 + >>> sale.untaxed_amount, sale.tax_amount, sale.total_amount + (Decimal('50.00'), Decimal('5.00'), Decimal('55.00')) + + +Create a sale line delete log it's was printed:: + + >>> sale.reload() + >>> sale.lines[0].delete() + >>> sale.lines[1].delete() + >>> sale.save() + >>> len(sale.lines) + 1 + + >>> sale.reload() + >>> len(sale.delete_lines) + 1 + + >>> sale.delete_lines[0] + proteus.Model.get('sale.line_deleted')(1) + >>> assert isinstance(sale.delete_lines[0], Model.get('sale.line_deleted')), "it's not instance SaleLineDeleted" diff --git a/tryton.cfg b/tryton.cfg index 602ca5a..5a7c753 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -1,5 +1,5 @@ [tryton] -version=7.6.0 +version=6.8.0 depends: ir res