Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions addons/l10n_ar_pos/tests/test_pos_ar.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ def setUpClass(cls):

cls.bank_pm = cls.env['pos.payment.method'].sudo().create({
'name': 'Bank',
'type': 'bank',
'journal_id': cls.company_data['default_journal_bank'].id,
'receivable_account_id': cls.pos_receivable_bank.id,
'outstanding_account_id': cls.outstanding_bank.id,
'company_id': cls.company.id,
})
cls.cash_pm = cls.env['pos.payment.method'].sudo().create({
'name': 'Cash',
'type': 'cash',
'journal_id': cls.company_data['default_journal_cash'].id,
'receivable_account_id': cls.pos_receivable_bank.id,
'outstanding_account_id': cls.outstanding_bank.id,
Expand Down
2 changes: 1 addition & 1 deletion addons/l10n_ar_pos/views/templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<attribute name="t-if">pos_order.company_id.country_code != 'AR'</attribute>
</xpath>
<xpath expr="//div[@id='get_my_invoice']/.." position="after">
<h4 class="text-danger" t-if="pos_order.company_id.country_code == 'AR' and not pos_order.is_invoiced">Invoice not available. You can contact us for more info</h4>
<h4 class="text-danger" t-if="pos_order.company_id.country_code == 'AR' and not pos_order.is_singly_invoiced">Invoice not available. You can contact us for more info</h4>
</xpath>

<!-- If the user is NOT log in we should hide the partner form, this one lost functionality because the get my invoice button is not shown and then the partner info is never save. In they want they can sign up and fill data from there -->
Expand Down
1 change: 0 additions & 1 deletion addons/l10n_be_pos_sale/tests/test_l10n_be_pos_sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def test_pos_branch_company_access(self):
b_pos_config = self.env['pos.config'].with_company(branch).create({
'name': 'Main',
'journal_id': self.company_data['default_journal_sale'].id,
'invoice_journal_id': self.company_data['default_journal_sale'].id,
'payment_method_ids': [(4, bank_payment_method.id)],
})

Expand Down
2 changes: 1 addition & 1 deletion addons/l10n_ch_pos/tests/test_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def _get_main_company(cls):
def test_l10n_ch_pos_pay_later_invoice_has_bank_partner(self):
customer_account_payment_method = self.env['pos.payment.method'].create({
'name': 'Customer Account',
'split_transactions': True,
'type': 'pay_later',
})
self.main_pos_config.write({
'payment_method_ids': [Command.link(customer_account_payment_method.id)],
Expand Down
2 changes: 1 addition & 1 deletion addons/l10n_es_edi_tbai_pos/models/pos_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def _l10n_es_tbai_create_edi_document(self, cancel=False):
def _l10n_es_tbai_get_values(self):
self.ensure_one()

base_lines = self.lines._prepare_tax_base_line_values()
base_lines = self.lines._prepare_base_lines_for_taxes_computation()
for base_line in base_lines:
base_line['name'] = base_line['record'].name
self.env['l10n_es_edi_tbai.document']._add_base_lines_tax_amounts(base_lines, self.company_id)
Expand Down
2 changes: 1 addition & 1 deletion addons/l10n_es_edi_verifactu_pos/models/pos_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def _l10n_es_edi_verifactu_get_record_values(self, cancellation=False):
'clave_regimen': clave_regimen,
})

base_lines = self.lines._prepare_tax_base_line_values()
base_lines = self.lines._prepare_base_lines_for_taxes_computation()
vals['tax_details'] = self.env['l10n_es_edi_verifactu.document']._get_tax_details(base_lines, company)

return vals
Expand Down
8 changes: 5 additions & 3 deletions addons/l10n_es_edi_verifactu_pos/tests/test_pos_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ def setUpClass(cls):
def with_pos_session(self):
session = self.open_new_session(0.0)
yield session
session.post_closing_cash_details(0.0)
session.close_session_from_ui()
cash_pm = self.config._get_cash_payment_method()
session.close_session_from_ui({
cash_pm.id: 0,
})

def _create_order(self, data):
date_order = data.pop('date_order', None)
Expand Down Expand Up @@ -140,7 +142,7 @@ def test_order_not_invoiced(self):
})
refund.l10n_es_edi_verifactu_refund_reason = 'R5'
refund_payment.with_context(**payment_context).check()
self.pos_session.action_pos_session_validate()
self.pos_session.close_session_from_ui()

self.assertRecordValues(order, [{
'l10n_es_edi_verifactu_state': 'accepted',
Expand Down
10 changes: 1 addition & 9 deletions addons/l10n_es_pos/static/tests/tours/spanish_pos_tour.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,9 @@ registry.category("web_tour.tours").add("l10n_es_pos_settle_account_due", {
Dialog.confirm("Open Register"),
ProductScreen.clickPartnerButton(),
PartnerList.settleCustomerAccount("Partner Test 1", "10.0", "TSJ/", "/00001", true),
ProductScreen.clickPayButton(),
PaymentScreen.clickPaymentMethod("Bank"),
PaymentScreen.clickValidate(),
Chrome.confirmPopup(),
FeedbackScreen.isShown(),
FeedbackScreen.checkTicketData({
payment_lines: [
{ name: "Bank", amount: "10.0" },
{ name: "Customer Account", amount: "-10.0" },
],
}),
ProductScreen.isShown(),
Chrome.endTour(),
].flat(),
});
Expand Down
16 changes: 8 additions & 8 deletions addons/l10n_es_pos/tests/test_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def _get_main_company(cls):
def test_spanish_pos(self):
split_payment_method = self.env['pos.payment.method'].create({
'name': 'Customer Account',
'split_transactions': True,
'type': 'pay_later',
})
self.main_pos_config.payment_method_ids = [(4, split_payment_method.id)]

Expand All @@ -30,7 +30,7 @@ def test_spanish_pos(self):
'code': 'SIMP',
})
def get_number_of_regular_invoices():
return self.env['account.move'].search_count([('journal_id', '=', self.main_pos_config.invoice_journal_id.id), ('l10n_es_is_simplified', '=', False), ('pos_order_ids', '!=', False)])
return self.env['account.move'].search_count([('journal_id', '=', self.main_pos_config.journal_id.id), ('l10n_es_is_simplified', '=', False), ('pos_order_ids', '!=', False)])
initial_number_of_regular_invoices = get_number_of_regular_invoices()
self.main_pos_config.l10n_es_simplified_invoice_journal_id = simp
# this `limit` value is linked to the `SIMPLIFIED_INVOICE_LIMIT` const in the tour
Expand All @@ -49,7 +49,7 @@ def test_l10n_es_pos_reconcile(self):
# create customer account payment method
self.customer_account_payment_method = self.env['pos.payment.method'].create({
'name': 'Customer Account',
'split_transactions': True,
'type': 'pay_later',
})
# add customer account payment method to pos config
self.main_pos_config.write({
Expand Down Expand Up @@ -89,7 +89,7 @@ def test_l10n_es_pos_reconcile(self):
order_payment.with_context(**payment_context).check()

self.assertEqual(self.partner_test_1.total_due, 10)
current_session.action_pos_session_closing_control()
current_session.close_session_from_ui()

self.main_pos_config.with_user(self.pos_admin).open_ui()
self.start_tour("/pos/ui/%d" % self.main_pos_config.id, 'l10n_es_pos_settle_account_due', login="accountman")
Expand Down Expand Up @@ -118,11 +118,11 @@ def test_spanish_pos_invoice_no_certificate(self):
'price_unit': 100,
'qty': 1.0,
'tax_ids': self.product_a.taxes_id,
'price_subtotal': 85,
'price_subtotal_incl': 100,
'price_subtotal': 100,
'price_subtotal_incl': 115,
'discount': 0,
})],
'amount_total': 100,
'amount_total': 115,
'amount_tax': 15,
'amount_paid': 0,
'amount_return': 0,
Expand All @@ -131,7 +131,7 @@ def test_spanish_pos_invoice_no_certificate(self):

context_make_payment = {"active_ids": [self.pos_order_pos0.id], "active_id": self.pos_order_pos0.id}
self.pos_make_payment_0 = self.env['pos.make.payment'].with_context(context_make_payment).create({
'amount': 100.0,
'amount': 115.0,
'payment_method_id': self.main_pos_config.payment_method_ids[0].id,
})
context_payment = {'active_id': self.pos_order_pos0.id}
Expand Down
6 changes: 5 additions & 1 deletion addons/l10n_fr_pos_cert/tests/test_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ def setUpClass(cls):
super().setUpClass()

def test_hashes_should_be_equal_if_no_alteration(self):
journal = self.env['account.journal']._ensure_company_account_journal()
if self.pos_config_usd.journal_id != journal:
self.pos_config_usd.journal_id = journal

product1 = self.env['product.product'].create({
'name': 'product1',
})
Expand Down Expand Up @@ -79,6 +83,6 @@ def test_hashes_should_be_equal_if_no_alteration(self):
posted_order = self.env['pos.order'].search([('uuid', '=', '12345-123-1234')])
self.assertEqual(posted_order.state, 'paid')

self.pos_config_usd.current_session_id.action_pos_session_closing_control()
self.pos_config_usd.current_session_id.close_session_from_ui()

self.assertEqual(posted_order.l10n_fr_hash, posted_order._compute_hash(''))
2 changes: 1 addition & 1 deletion addons/l10n_fr_pos_cert/tests/test_string_to_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,5 @@ def test_string_to_hash(self):
{'amount': 8900, 'payment_method': self.cash_pm1},
{'amount': 11000, 'payment_method': self.pay_later_pm}
])
self.basic_config.current_session_id.action_pos_session_closing_control()
self.basic_config.current_session_id.close_session_from_ui()
self.assertEqual(order.l10n_fr_string_to_hash, self._compute_string_to_hash_original(order))
5 changes: 3 additions & 2 deletions addons/l10n_id_pos/tests/test_qris_pos.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@ def setUpClass(cls):

cls.bank_pm = cls.env['pos.payment.method'].sudo().create({
'name': 'Cash',
'journal_id': cls.company_data['default_journal_bank'].id,
'type': 'cash',
'journal_id': cls.company_data['default_journal_cash'].id,
'receivable_account_id': cls.pos_receivable_bank.id,
'outstanding_account_id': cls.outstanding_bank.id,
'company_id': cls.company.id,
})
cls.qris_pm = cls.env['pos.payment.method'].sudo().create({
'name': 'QRIS',
'type': 'bank',
'journal_id': cls.company_data['default_journal_bank'].id,
'receivable_account_id': cls.pos_receivable_bank.id,
'outstanding_account_id': cls.outstanding_bank.id,
Expand Down
2 changes: 1 addition & 1 deletion addons/l10n_in_pos/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AccountMove(models.Model):
@api.depends('pos_session_ids', 'reversed_pos_order_id')
def _compute_l10n_in_state_id(self):
res = super()._compute_l10n_in_state_id()
to_compute = self.filtered(lambda m: m.country_code == 'IN' and not m.l10n_in_state_id and m.journal_id.type == 'general' and (m.pos_session_ids or m.reversed_pos_order_id))
to_compute = self.filtered(lambda m: m.country_code == 'IN' and not m.l10n_in_state_id and m.journal_id.type == 'sale' and (m.pos_session_ids or m.reversed_pos_order_id))
for move in to_compute:
move.l10n_in_state_id = move.company_id.state_id
return res
37 changes: 31 additions & 6 deletions addons/l10n_in_pos/models/pos_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,35 @@
class PosOrder(models.Model):
_inherit = 'pos.order'

def _prepare_product_aml_dict(self, base_line_vals, update_base_line_vals, rate, sign):
res = super()._prepare_product_aml_dict(base_line_vals, update_base_line_vals, rate, sign)
if self.company_id.account_fiscal_country_id.code == 'IN':
res.update({
'l10n_in_hsn_code': base_line_vals['l10n_in_hsn_code'],
})
def _grouping_function(self, line):
res = super()._grouping_function(line) # Returns mappingproxy (immutable)
if self.config_id.company_id.l10n_in_is_gst_registered:
res = dict(res) # Convert to mutable dict
res['l10n_in_hsn_code'] = line.get('l10n_in_hsn_code', '')
res['product_uom_id'] = line.get('product_uom_id', '')
return res

def _prepare_account_move_line_data(self, aggregate=True):
lines = super()._prepare_account_move_line_data(aggregate)
if aggregate:
return lines

for line in lines:
move = line.get('account.move.line')
meta = line.get('metadata')

if self.config_id.company_id.l10n_in_is_gst_registered and meta:
pos_line = meta.get('line') if meta else None
if not pos_line:
continue
move["l10n_in_hsn_code"] = pos_line.l10n_in_hsn_code
move["product_uom_id"] = pos_line.product_uom_id.id

return lines

def _prepare_move_line_vals_from_base_line(self, base_line):
values = super()._prepare_move_line_vals_from_base_line(base_line)
if self.config_id.company_id.l10n_in_is_gst_registered:
values["l10n_in_hsn_code"] = base_line.get("l10n_in_hsn_code", "")
values["product_uom_id"] = base_line.get("product_uom_id", "").id
return values
13 changes: 7 additions & 6 deletions addons/l10n_in_pos/models/pos_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ def _load_pos_data_fields(self, config):
params += ['l10n_in_hsn_code']
return params

def _prepare_base_line_for_taxes_computation(self):
res = super()._prepare_base_line_for_taxes_computation()
def _prepare_base_lines_for_taxes_computation(self):
base_lines = super()._prepare_base_lines_for_taxes_computation()
if self.company_id.l10n_in_is_gst_registered:
res.update({
'l10n_in_hsn_code': self.l10n_in_hsn_code,
})
return res
for index, line in enumerate(self):
base_lines[index].update({
'l10n_in_hsn_code': line.l10n_in_hsn_code,
})
return base_lines
48 changes: 28 additions & 20 deletions addons/l10n_in_pos/models/pos_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,6 @@
class PosSession(models.Model):
_inherit = 'pos.session'

def _get_sale_key(self, base_line):
res = super()._get_sale_key(base_line)
if self.config_id.company_id.l10n_in_is_gst_registered:
res.update({
'uom_id': base_line['uom_id'].id,
'l10n_in_hsn_code': base_line['l10n_in_hsn_code'],
})
return res

def _get_sale_vals(self, key, sale_vals):
res = super()._get_sale_vals(key, sale_vals)
if self.config_id.company_id.l10n_in_is_gst_registered:
res.update({
'l10n_in_hsn_code': key['l10n_in_hsn_code'],
'product_uom_id': key['uom_id'],
})
return res

def set_missing_hsn_codes_in_pos_orders(self):
self.ensure_one()
PosOrderLine = self.env['pos.order.line']
Expand All @@ -40,7 +22,33 @@ def set_missing_hsn_codes_in_pos_orders(self):
line.l10n_in_hsn_code = line.product_id.l10n_in_hsn_code

# Lines where product itself is missing HSN
missing_hsn_lines = PosOrderLine.search(
return PosOrderLine.search(
base_domain + [('product_id.l10n_in_hsn_code', '=', False)]
)
return missing_hsn_lines

def _prepare_account_move_line_commands_for_reversal(self, order, invoice_to_reverse):
commands = super()._prepare_account_move_line_commands_for_reversal(order, invoice_to_reverse)
if not order.config_id.company_id.l10n_in_is_gst_registered:
return commands

product_lines = invoice_to_reverse.line_ids.filtered(
lambda line: line.display_type == 'product',
)

for idx, line in enumerate(product_lines):
command = commands[idx]
command[2]["l10n_in_hsn_code"] = line.l10n_in_hsn_code
command[2]["product_uom_id"] = line.product_uom_id.id

return commands

def _validate_session_accounting(self, check_validity=True):
result = super()._validate_session_accounting(check_validity=check_validity)
gst_sessions = self.filtered(
lambda session: session.company_id.l10n_in_is_gst_registered
and (session.sales_move_id or session.refunds_move_id),
)
if gst_sessions:
tax_tags_dict = self.env['account.move.line']._get_l10n_in_tax_tag_ids()
(gst_sessions.sales_move_id | gst_sessions.refunds_move_id).line_ids._set_l10n_in_gstr_section(tax_tags_dict)
return result
2 changes: 1 addition & 1 deletion addons/l10n_in_pos/receipt/pos_order_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def order_receipt_generate_data(self, basic_receipt=False):
data = super().order_receipt_generate_data(basic_receipt)

if self.company_id.country_id.code == 'IN':
base_lines = self.lines._prepare_tax_base_line_values()
base_lines = self.lines._prepare_base_lines_for_taxes_computation()
self.env['account.tax']._add_tax_details_in_base_lines(base_lines, self.company_id)
self.env['account.tax']._round_base_lines_tax_details(base_lines, self.company_id)
l10n_in_hsn_summary = self.env['account.tax']._l10n_in_get_hsn_summary_table(base_lines, False)
Expand Down
6 changes: 4 additions & 2 deletions addons/l10n_in_pos/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ def with_pos_session(self):
"""Opens a new POS session and ensures it is closed properly."""
session = self.open_new_session(0.0)
yield session
session.post_closing_cash_details(0.0)
session.close_session_from_ui()
cash_pm = self.config._get_cash_payment_method()
session.close_session_from_ui({
cash_pm.id: 0,
})

def _create_order(self, ui_data):
"""Helper to create a POS order from UI data."""
Expand Down
8 changes: 4 additions & 4 deletions addons/l10n_in_pos/tests/test_gstr_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def test_b2cs_gstr_section_with_pos_order(self):
],
'payments': [(self.bank_pm1, 630.0)],
})
session.action_pos_session_closing_control()
pos_entry_lines = session.move_id.line_ids
session.close_session_from_ui()
pos_entry_lines = session.move_ids.line_ids
for line in pos_entry_lines.filtered(lambda l: l.display_type in ('product, tax')):
self.assertEqual(line.l10n_in_gstr_section, 'sale_b2cs')

Expand All @@ -31,7 +31,7 @@ def test_nil_rated_gstr_section_with_pos_order(self):
'payments': [(self.bank_pm1, 900.0)],
'customer': self.partner_a,
})
session.action_pos_session_closing_control()
pos_entry_lines = session.move_id.line_ids
session.close_session_from_ui()
pos_entry_lines = session.move_ids.line_ids
for line in pos_entry_lines.filtered(lambda l: l.display_type in ('product, tax')):
self.assertEqual(line.l10n_in_gstr_section, 'sale_nil_rated')
4 changes: 4 additions & 0 deletions addons/l10n_in_pos/tests/test_hsn_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ def test_l10n_in_hsn_summary_pos(self):
# are exactly the same.
tests = self._test_l10n_in_hsn_summary_1()
test1 = next(tests)
self.env.company.write({
'street': 'street',
'state_id': self.env['res.country.state'].search([], limit=1).id,
})
self.ensure_products_on_document(test1[1], 'product_1')
with self.with_new_session(user=self.pos_user):
self.start_pos_tour('test_l10n_in_hsn_summary_pos')
1 change: 0 additions & 1 deletion addons/l10n_in_pos/tests/test_pos_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def test_invoice_order_after_session_closed(self):
# with self.with_pos_session() as session2:
pos_order_going_to_invoice.partner_id = self.partner_a
pos_order_going_to_invoice.action_pos_order_invoice()
# session2.action_pos_session_closing_control()

# Confirm that reversal move(s) are now set
reversal_moves = self.env['account.move'].search([('reversed_pos_order_id', '=', pos_order_going_to_invoice.id)])
Expand Down
Loading