Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
odoo
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cooperatic-foodcoops
odoo
Commits
bc2a0f31
Commit
bc2a0f31
authored
Feb 22, 2022
by
Etienne Freiss
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
develop
parent
59273361
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
1 deletions
+86
-1
__init__.py
lacagette_addons/pos_meal_voucher/models/__init__.py
+1
-0
account_bank_statement_line.py
...ns/pos_meal_voucher/models/account_bank_statement_line.py
+13
-0
pos_order.py
lacagette_addons/pos_meal_voucher/models/pos_order.py
+72
-1
No files found.
lacagette_addons/pos_meal_voucher/models/__init__.py
View file @
bc2a0f31
...
@@ -4,3 +4,4 @@ from . import pos_config
...
@@ -4,3 +4,4 @@ from . import pos_config
from
.
import
pos_order
from
.
import
pos_order
from
.
import
product_category
from
.
import
product_category
from
.
import
product_template
from
.
import
product_template
from
.
import
account_bank_statement_line
lacagette_addons/pos_meal_voucher/models/account_bank_statement_line.py
0 → 100644
View file @
bc2a0f31
# Copyright (C) 2020 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from
openerp
import
api
,
fields
,
models
class
AccountBankStatementLine
(
models
.
Model
):
_inherit
=
'account.bank.statement.line'
statement_note
=
fields
.
Char
(
string
=
"Number ID of the meal voucher"
)
lacagette_addons/pos_meal_voucher/models/pos_order.py
View file @
bc2a0f31
...
@@ -3,7 +3,11 @@
...
@@ -3,7 +3,11 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from
openerp
import
models
from
openerp
import
models
import
time
from
datetime
import
datetime
import
uuid
from
openerp
import
tools
from
openerp.osv
import
fields
class
PosOrder
(
models
.
Model
):
class
PosOrder
(
models
.
Model
):
_inherit
=
'pos.order'
_inherit
=
'pos.order'
...
@@ -13,3 +17,69 @@ class PosOrder(models.Model):
...
@@ -13,3 +17,69 @@ class PosOrder(models.Model):
res
[
"statement_note"
]
=
ui_paymentline
.
get
(
"statement_note"
,
False
)
res
[
"statement_note"
]
=
ui_paymentline
.
get
(
"statement_note"
,
False
)
return
res
return
res
def
add_payment
(
self
,
cr
,
uid
,
order_id
,
data
,
context
=
None
):
# From odoo/addons/point_of_sale/point_of_sale.py line 1107
"""Create a new payment for the order"""
context
=
dict
(
context
or
{})
statement_line_obj
=
self
.
pool
.
get
(
'account.bank.statement.line'
)
property_obj
=
self
.
pool
.
get
(
'ir.property'
)
order
=
self
.
browse
(
cr
,
uid
,
order_id
,
context
=
context
)
date
=
data
.
get
(
'payment_date'
,
time
.
strftime
(
'
%
Y-
%
m-
%
d'
))
if
len
(
date
)
>
10
:
timestamp
=
datetime
.
strptime
(
date
,
tools
.
DEFAULT_SERVER_DATETIME_FORMAT
)
ts
=
fields
.
datetime
.
context_timestamp
(
cr
,
uid
,
timestamp
,
context
)
date
=
ts
.
strftime
(
tools
.
DEFAULT_SERVER_DATE_FORMAT
)
args
=
{
'amount'
:
data
[
'amount'
],
'date'
:
date
,
'name'
:
order
.
name
+
': '
+
(
data
.
get
(
'payment_name'
,
''
)
or
''
),
'partner_id'
:
order
.
partner_id
and
self
.
pool
.
get
(
"res.partner"
)
.
_find_accounting_partner
(
order
.
partner_id
)
.
id
or
False
,
}
journal_id
=
data
.
get
(
'journal'
,
False
)
statement_id
=
data
.
get
(
'statement_id'
,
False
)
assert
journal_id
or
statement_id
,
"No statement_id or journal_id passed to the method!"
journal
=
self
.
pool
[
'account.journal'
]
.
browse
(
cr
,
uid
,
journal_id
,
context
=
context
)
# use the company of the journal and not of the current user
company_cxt
=
dict
(
context
,
force_company
=
journal
.
company_id
.
id
)
account_def
=
property_obj
.
get
(
cr
,
uid
,
'property_account_receivable_id'
,
'res.partner'
,
context
=
company_cxt
)
args
[
'account_id'
]
=
(
order
.
partner_id
and
order
.
partner_id
.
property_account_receivable_id
\
and
order
.
partner_id
.
property_account_receivable_id
.
id
)
or
(
account_def
and
account_def
.
id
)
or
False
if
not
args
[
'account_id'
]:
if
not
args
[
'partner_id'
]:
msg
=
_
(
'There is no receivable account defined to make payment.'
)
else
:
msg
=
_
(
'There is no receivable account defined to make payment for the partner: "
%
s" (id:
%
d).'
)
%
(
order
.
partner_id
.
name
,
order
.
partner_id
.
id
,)
raise
UserError
(
msg
)
context
.
pop
(
'pos_session_id'
,
False
)
for
statement
in
order
.
session_id
.
statement_ids
:
if
statement
.
id
==
statement_id
:
journal_id
=
statement
.
journal_id
.
id
break
elif
statement
.
journal_id
.
id
==
journal_id
:
statement_id
=
statement
.
id
break
if
not
statement_id
:
raise
UserError
(
_
(
'You have to open at least one cashbox.'
))
statement_note
=
''
if
data
[
'statement_note'
]
!=
''
:
statement_note
=
data
[
'statement_note'
]
args
.
update
({
'statement_id'
:
statement_id
,
'pos_statement_id'
:
order_id
,
'journal_id'
:
journal_id
,
'ref'
:
order
.
session_id
.
name
,
'statement_note'
:
statement_note
,
})
statement_line_obj
.
create
(
cr
,
uid
,
args
,
context
=
context
)
return
statement_id
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment