Skip to content

Commit 9781475

Browse files
committedJun 26, 2024
[FIX] point_of_sale, l10n_ch_pos: missing bank recipient pos invoice
Steps: - Install l10n_fr and make sure fr company has tax id filled - Go to bank journal and set a bank account number - Go to Customer invoice journal and check `Factur-X` in the Advenced Settings tab - Create a french customer F with an email address - Open a pos session, and make an invoice forF for a product with tax, select Bank payment method and confirm - Go to invoices and select the newly created invoice -> "Error occured while creating the EDI document" Cause: The field `partner_bank_id` is not set from the pos order to the invoice cbe1cf5 added a condition specifically for swiss localisation. Fix: Movr the condition to a bridge module for swiss localisation opw-3992498 closes odoo#170933 X-original-commit: ac005d5 Signed-off-by: Vlad Stroia (vlst) <[email protected]> Signed-off-by: Guillaume Vanleynseele (guva) <[email protected]>
1 parent bd8a8dc commit 9781475

File tree

5 files changed

+39
-6
lines changed

5 files changed

+39
-6
lines changed
 

‎addons/l10n_ch_pos/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
3+
from . import models

‎addons/l10n_ch_pos/__manifest__.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
{
3+
'name': 'Swiss - Point of Sale',
4+
'author': 'Odoo PS',
5+
'category': 'Accounting/Localizations/Point of Sale',
6+
'description': """
7+
Swiss POS Localization
8+
=======================================================
9+
""",
10+
'depends': ['l10n_ch', 'point_of_sale'],
11+
'auto_install': True,
12+
'installable': True,
13+
'license': 'LGPL-3',
14+
}

‎addons/l10n_ch_pos/models/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
3+
from . import pos_order
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
from odoo import models
3+
4+
5+
class PosOrder(models.Model):
6+
_name = "pos.order"
7+
_inherit = ["pos.order"]
8+
9+
def _get_partner_bank_id(self):
10+
bank_partner_id = super()._get_partner_bank_id()
11+
swiss_order = self.filtered(lambda o: o.company_id.country_code == 'CH')
12+
if swiss_order:
13+
has_pay_later = any(not pm.journal_id for pm in swiss_order.payment_ids.mapped('payment_method_id'))
14+
bank_partner_id = bank_partner_id if has_pay_later else False
15+
return bank_partner_id

‎addons/point_of_sale/models/pos_order.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -528,12 +528,10 @@ def _get_rounded_amount(self, amount, force_round=False):
528528

529529
def _get_partner_bank_id(self):
530530
bank_partner_id = False
531-
has_pay_later = any(not pm.journal_id for pm in self.payment_ids.mapped('payment_method_id'))
532-
if has_pay_later:
533-
if self.amount_total <= 0 and self.partner_id.bank_ids:
534-
bank_partner_id = self.partner_id.bank_ids[0].id
535-
elif self.amount_total >= 0 and self.company_id.partner_id.bank_ids:
536-
bank_partner_id = self.company_id.partner_id.bank_ids[0].id
531+
if self.amount_total <= 0 and self.partner_id.bank_ids:
532+
bank_partner_id = self.partner_id.bank_ids[0].id
533+
elif self.amount_total >= 0 and self.company_id.partner_id.bank_ids:
534+
bank_partner_id = self.company_id.partner_id.bank_ids[0].id
537535
return bank_partner_id
538536

539537
def _create_invoice(self, move_vals):

0 commit comments

Comments
 (0)
Please sign in to comment.