[MIG] pos_check_deposit to v18
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py
|
||||
index 31e39105612..fe74620369a 100644
|
||||
index 546dbece6c4..0add2935f52 100644
|
||||
--- a/addons/point_of_sale/models/pos_session.py
|
||||
+++ b/addons/point_of_sale/models/pos_session.py
|
||||
@@ -928,8 +928,13 @@ class PosSession(models.Model):
|
||||
@@ -1123,8 +1123,13 @@ class PosSession(models.Model):
|
||||
if not payment_method.journal_id:
|
||||
return self.env['account.move.line']
|
||||
outstanding_account = payment_method.outstanding_account_id or self.company_id.account_journal_payment_debit_account_id
|
||||
outstanding_account = payment_method.outstanding_account_id
|
||||
- accounting_partner = self.env["res.partner"]._find_accounting_partner(payment.partner_id)
|
||||
- destination_account = accounting_partner.property_account_receivable_id
|
||||
+ # HACK for pos_check_deposit
|
||||
@@ -14,20 +14,31 @@ index 31e39105612..fe74620369a 100644
|
||||
+ destination_account = accounting_partner.property_account_receivable_id
|
||||
+ else:
|
||||
+ accounting_partner = False
|
||||
+ destination_account = self._get_receivable_account(payment.payment_method_id)
|
||||
+ destination_account = self._get_receivable_account(payment_method)
|
||||
|
||||
if float_compare(amounts['amount'], 0, precision_rounding=self.currency_id.rounding) < 0:
|
||||
# revert the accounts because account.payment doesn't accept negative amount.
|
||||
@@ -937,7 +942,7 @@ class PosSession(models.Model):
|
||||
@@ -1132,7 +1137,8 @@ class PosSession(models.Model):
|
||||
|
||||
account_payment = self.env['account.payment'].create({
|
||||
'amount': abs(amounts['amount']),
|
||||
- 'partner_id': payment.partner_id.id,
|
||||
+ # HACK for pos_check_deposit
|
||||
+ 'partner_id': accounting_partner and accounting_partner.id or False,
|
||||
'journal_id': payment_method.journal_id.id,
|
||||
'force_outstanding_account_id': outstanding_account.id,
|
||||
'destination_account_id': destination_account.id,
|
||||
@@ -1097,8 +1102,8 @@ class PosSession(models.Model):
|
||||
@@ -1141,7 +1147,8 @@ class PosSession(models.Model):
|
||||
'pos_session_id': self.id,
|
||||
})
|
||||
account_payment.action_post()
|
||||
- return account_payment.move_id.line_ids.filtered(lambda line: line.account_id == accounting_partner.property_account_receivable_id)
|
||||
+ # HACK for pos_check_deposit
|
||||
+ return account_payment.move_id.line_ids.filtered(lambda line: line.account_id == destination_account)
|
||||
|
||||
def _create_cash_statement_lines_and_cash_move_lines(self, data):
|
||||
# Create the split and combine cash statement lines and account move lines.
|
||||
@@ -1292,8 +1299,8 @@ class PosSession(models.Model):
|
||||
lines.filtered(lambda line: not line.reconciled).reconcile()
|
||||
|
||||
for payment, lines in payment_to_receivable_lines.items():
|
||||
@@ -38,15 +49,16 @@ index 31e39105612..fe74620369a 100644
|
||||
|
||||
# Reconcile invoice payments' receivable lines. But we only do when the account is reconcilable.
|
||||
# Though `account_default_pos_receivable_account_id` should be of type receivable, there is currently
|
||||
@@ -1176,15 +1181,17 @@ class PosSession(models.Model):
|
||||
@@ -1333,16 +1340,17 @@ class PosSession(models.Model):
|
||||
return self._credit_amounts(partial_args, amount, amount_converted)
|
||||
|
||||
def _get_split_receivable_vals(self, payment, amount, amount_converted):
|
||||
- accounting_partner = self.env["res.partner"]._find_accounting_partner(payment.partner_id)
|
||||
- if not accounting_partner:
|
||||
- raise UserError(_("You have enabled the \"Identify Customer\" option for %s payment method,"
|
||||
- "but the order %s does not contain a customer.") % (payment.payment_method_id.name,
|
||||
- payment.pos_order_id.name))
|
||||
- raise UserError(_("You have enabled the \"Identify Customer\" option for %(payment_method)s payment method,"
|
||||
- "but the order %(order)s does not contain a customer.",
|
||||
- payment_method=payment.payment_method_id.name,
|
||||
- order=payment.pos_order_id.name))
|
||||
+ # HACK for pos_check_deposit
|
||||
+ if payment.partner_id:
|
||||
+ accounting_partner = self.env["res.partner"]._find_accounting_partner(payment.partner_id)
|
||||
@@ -63,17 +75,18 @@ index 31e39105612..fe74620369a 100644
|
||||
'name': '%s - %s' % (self.name, payment.payment_method_id.name),
|
||||
}
|
||||
return self._debit_amounts(partial_vals, amount, amount_converted)
|
||||
diff --git a/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js b/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js
|
||||
index b9a237eb34c..62ad67e9517 100644
|
||||
--- a/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js
|
||||
+++ b/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js
|
||||
@@ -288,7 +288,8 @@ odoo.define('point_of_sale.PaymentScreen', function (require) {
|
||||
return false;
|
||||
}
|
||||
|
||||
- const splitPayments = this.paymentLines.filter(payment => payment.payment_method.split_transactions)
|
||||
+ // HACK for pos_check_deposit
|
||||
+ const splitPayments = this.paymentLines.filter(payment => payment.payment_method.identify_customer)
|
||||
if (splitPayments.length && !this.currentOrder.get_partner()) {
|
||||
const paymentMethod = splitPayments[0].payment_method
|
||||
const { confirmed } = await this.showPopup('ConfirmPopup', {
|
||||
diff --git a/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.js b/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.js
|
||||
index c94484b8a26..39d3b66cc63 100644
|
||||
--- a/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.js
|
||||
+++ b/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.js
|
||||
@@ -407,8 +407,9 @@ export class PaymentScreen extends Component {
|
||||
}
|
||||
}
|
||||
async _askForCustomerIfRequired() {
|
||||
+ // HACK for pos_check_deposit
|
||||
const splitPayments = this.paymentLines.filter(
|
||||
- (payment) => payment.payment_method_id.split_transactions
|
||||
+ (payment) => payment.payment_method_id.identify_customer
|
||||
);
|
||||
if (splitPayments.length && !this.currentOrder.get_partner()) {
|
||||
const paymentMethod = splitPayments[0].payment_method_id;
|
||||
|
||||
Reference in New Issue
Block a user