-
-
Notifications
You must be signed in to change notification settings - Fork 582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[10.0] pos_invoice_pay: store POS session in payment record #1457
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
`1.1.0` | ||
------- | ||
|
||
**Improvement:** Store POS session in payment record | ||
|
||
`1.0.6` | ||
------- | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,5 +1,6 @@ | ||||||||||||||||||||
# Copyright 2018 Artyom Losev | ||||||||||||||||||||
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr> | ||||||||||||||||||||
# Copyright 2021 Eugene Molotov <https://github.com/em230418> | ||||||||||||||||||||
# License MIT (https://opensource.org/licenses/MIT). | ||||||||||||||||||||
|
||||||||||||||||||||
from odoo import api, fields, models | ||||||||||||||||||||
|
@@ -49,7 +50,7 @@ def process_invoice_payment(self, invoice): | |||||||||||||||||||
"partner_type": "customer", | ||||||||||||||||||||
"payment_difference_handling": payment_difference_handling, | ||||||||||||||||||||
"writeoff_account_id": writeoff_acc_id, | ||||||||||||||||||||
"paid_by_pos": True, | ||||||||||||||||||||
"pos_session_id": invoice["data"]["pos_session_id"], | ||||||||||||||||||||
"cashier": cashier, | ||||||||||||||||||||
} | ||||||||||||||||||||
payment = self.env["account.payment"].create(vals) | ||||||||||||||||||||
|
@@ -66,9 +67,15 @@ def process_invoices_creation(self, sale_order_id): | |||||||||||||||||||
class AccountPayment(models.Model): | ||||||||||||||||||||
_inherit = "account.payment" | ||||||||||||||||||||
|
||||||||||||||||||||
paid_by_pos = fields.Boolean(default=False) | ||||||||||||||||||||
paid_by_pos = fields.Boolean(compute="_compute_paid_by_pos", store=True) | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Если поле не используется для поиска\фильтрации, то не обязательно сохранять в таблице значения
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Это поле используется для поиска pos-addons/pos_invoice_pay/report/report.py Lines 33 to 39 in 8b16c4d
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Может напрямую по новому полю искать? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Действительно можно, но дело в другом. Если какой-то сторонний модуль зависит от этого модуля и использует paid_by_pos, который изначально в базе хранится, то этот сторонний модуль сломается. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Может сторонний модуль сделает store=True ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ладно, я устал спорить. Просто обозначу как 10.0.2.0.0 и без store=True. |
||||||||||||||||||||
pos_session_id = fields.Many2one("pos.session") | ||||||||||||||||||||
cashier = fields.Many2one("res.users") | ||||||||||||||||||||
|
||||||||||||||||||||
@api.depends("pos_session_id") | ||||||||||||||||||||
def _compute_paid_by_pos(self): | ||||||||||||||||||||
for record in self: | ||||||||||||||||||||
record.paid_by_pos = bool(record.pos_session_id.id) | ||||||||||||||||||||
|
||||||||||||||||||||
|
||||||||||||||||||||
class AccountInvoice(models.Model): | ||||||||||||||||||||
_inherit = "account.invoice" | ||||||||||||||||||||
|
@@ -171,3 +178,9 @@ class PosConfig(models.Model): | |||||||||||||||||||
help="Ask for a cashier when fetch orders", | ||||||||||||||||||||
defaul=True, | ||||||||||||||||||||
) | ||||||||||||||||||||
|
||||||||||||||||||||
|
||||||||||||||||||||
class PosSession(models.Model): | ||||||||||||||||||||
_inherit = "pos.session" | ||||||||||||||||||||
|
||||||||||||||||||||
invoice_payment_ids = fields.One2many("account.payment", "pos_session_id") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше капитально поменять версию, т.к. там поля добавляются и нужно нажимать "Обновить модуль"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://gitlab.com/itpp/handbook/-/blob/master/technical-docs/__manifest__.md#version
Попадает под
y
.