From bb4a924cc65f461567a02a4bf5b7687d038368fa Mon Sep 17 00:00:00 2001 From: Joseph Caburnay Date: Thu, 4 Jun 2020 05:54:46 +0000 Subject: [PATCH] [IMP] point_of_sale: set invoicing by default --- addons/point_of_sale/models/pos_config.py | 11 ++++++++++- .../static/tests/tours/PaymentScreen.tour.js | 1 - 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/addons/point_of_sale/models/pos_config.py b/addons/point_of_sale/models/pos_config.py index 5259d3742dc..2a2acbe0cc5 100644 --- a/addons/point_of_sale/models/pos_config.py +++ b/addons/point_of_sale/models/pos_config.py @@ -196,7 +196,7 @@ class PosConfig(models.Model): tax_regime_selection = fields.Boolean("Tax Regime Selection value") start_category = fields.Boolean("Start Category", default=False) limit_categories = fields.Boolean("Restrict Product Categories") - module_account = fields.Boolean(string='Invoicing', help='Enables invoice generation from the Point of Sale.') + module_account = fields.Boolean(string='Invoicing', default=True, help='Enables invoice generation from the Point of Sale.') module_pos_restaurant = fields.Boolean("Is a Bar/Restaurant") module_pos_discount = fields.Boolean("Global Discounts") module_pos_loyalty = fields.Boolean("Loyalty Program") @@ -630,6 +630,7 @@ class PosConfig(models.Model): """ self.assign_payment_journals(company) self.generate_pos_journal(company) + self.setup_invoice_journal(company) def assign_payment_journals(self, company): for pos_config in self: @@ -668,3 +669,11 @@ class PosConfig(models.Model): 'sequence': 20 }) pos_config.write({'journal_id': pos_journal.id}) + + def setup_invoice_journal(self, company): + for pos_config in self: + invoice_journal_id = pos_config.invoice_journal_id or self.env['account.journal'].search([('type', '=', 'sale'), ('company_id', '=', company.id)], limit=1) + if invoice_journal_id: + pos_config.write({'invoice_journal_id': invoice_journal_id.id}) + else: + pos_config.write({'module_account': False}) diff --git a/addons/point_of_sale/static/tests/tours/PaymentScreen.tour.js b/addons/point_of_sale/static/tests/tours/PaymentScreen.tour.js index e9d88ccb7e5..6a58c5bf231 100644 --- a/addons/point_of_sale/static/tests/tours/PaymentScreen.tour.js +++ b/addons/point_of_sale/static/tests/tours/PaymentScreen.tour.js @@ -12,7 +12,6 @@ odoo.define('point_of_sale.tour.PaymentScreen', function (require) { ProductScreen.do.clickPayButton(); PaymentScreen.check.emptyPaymentlines('52.8'); - // Pay with cash, created line should have zero amount PaymentScreen.do.clickPaymentMethod('Cash'); PaymentScreen.do.pressNumpad('1 1'); PaymentScreen.check.selectedPaymentlineHas('Cash', '11.00');