[IMP] account,pos: better distinction between customer payments

Task 1934667

1. That's the partner type (and not the payment type) that should define if a payment is a customer or a supplier payment :
a. When the partner type on the payment is "customer", the payment should be considered as a customer payment
(and thus be visible from the menu customer payments)
b. When the partner type on the payment is "supplier", the payment should be considered as a supplier payment
(and thus be visible from the menu supplier payments)

2. The PoS should only create customer payments (you never pay suppliers through the PoS)
The payment created should be with a partner type "Customer"
But the partner field can stay empty if the customer wasn't set on the PoS Order

3. When I change the payment type while creating a payment from scratch, it shouldn't change the partner type
Example : I'm creating a payment for a reimbursement, I'll create it from the customer payments menu (as I'm paying a customer), I'll tick the payment type "Send money"
I don't expect the partner type to change to vendor.

closes odoo/odoo#32201

Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
This commit is contained in:
wan
2019-04-02 14:45:04 +00:00
parent 1774fcf778
commit 1fac092c35
5 changed files with 13 additions and 11 deletions
@@ -517,6 +517,8 @@ class AccountBankStatementLine(models.Model):
partner_type = 'supplier'
else:
partner_type = 'customer'
if not partner_type and self.env.context.get('default_partner_type'):
partner_type = self.env.context['default_partner_type']
currency = self.journal_id.currency_id or self.company_id.currency_id
payment_methods = (total > 0) and self.journal_id.inbound_payment_method_ids or self.journal_id.outbound_payment_method_ids
return {
+3 -3
View File
@@ -496,14 +496,14 @@ class account_payment(models.Model):
@api.onchange('payment_type')
def _onchange_payment_type(self):
if not self.invoice_ids:
if not self.invoice_ids and not self.partner_type:
# Set default partner type for the payment type
if self.payment_type == 'inbound':
self.partner_type = 'customer'
elif self.payment_type == 'outbound':
self.partner_type = 'supplier'
else:
self.partner_type = False
elif self.payment_type not in ('inbound', 'outbound'):
self.partner_type = False
# Set payment method domain
res = self._onchange_journal()
if not res.get('domain', {}):
@@ -92,8 +92,8 @@
<field name="partner_id" />
<field name="journal_id" />
<field name="company_id" groups="base.group_multi_company" />
<filter string="Vendor Payments" domain="[('payment_type','=','outbound')]" name="outbound_filter"/>
<filter string="Customer Payments" domain="[('payment_type','=','inbound')]" name="inbound_filter"/>
<filter string="Vendor Payments" domain="[('partner_type','=','supplier')]" name="outbound_filter"/>
<filter string="Customer Payments" domain="[('partner_type','=','customer')]" name="inbound_filter"/>
<filter string="Transfers" domain="[('payment_type','=','transfer')]" name="transfers_filter"/>
<separator/>
<filter string="Draft" domain="[('state','=','draft')]" name='state_draft'/>
+5 -5
View File
@@ -975,7 +975,7 @@ class PosOrder(models.Model):
self.env['account.bank.statement.line'].with_context(context).create(args)
self.amount_paid = sum(payment.amount for payment in self.statement_ids)
return args.get('statement_id', False)
def _prepare_refund_order_data(self, current_session=None):
"""
Prepare data for the creation of refund order based on the current order's data. Inheritance may inject its own data here
@@ -999,7 +999,7 @@ class PosOrder(models.Model):
'amount_total': -self.amount_total,
'amount_paid': 0,
}
@api.multi
def refund(self):
"""Create a copy of order for refund order"""
@@ -1245,10 +1245,10 @@ class ReportSaleDetails(models.AbstractModel):
SELECT aj.name, sum(amount) total
FROM account_bank_statement_line AS absl,
account_bank_statement AS abs,
account_journal AS aj
account_journal AS aj
WHERE absl.statement_id = abs.id
AND abs.journal_id = aj.id
AND absl.id IN %s
AND abs.journal_id = aj.id
AND absl.id IN %s
GROUP BY aj.name
""", (tuple(st_line_ids),))
payments = self.env.cr.dictfetchall()
+1 -1
View File
@@ -282,7 +282,7 @@ class PosSession(models.Model):
# Close CashBox
for session in self:
company_id = session.config_id.company_id.id
ctx = dict(self.env.context, force_company=company_id, company_id=company_id)
ctx = dict(self.env.context, force_company=company_id, company_id=company_id, default_partner_type='customer')
for st in session.statement_ids:
if abs(st.difference) > st.journal_id.amount_authorized_diff:
# The pos manager can close statements with maximums.