Skip to content

Commit c00ddb9

Browse files
committed
Merge branch 'release/2.2'
2 parents 465cebc + 0a5ba19 commit c00ddb9

File tree

2 files changed

+112
-1
lines changed

2 files changed

+112
-1
lines changed

magento/sales.py

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,117 @@ def cancel(self, order_increment_id):
119119
return bool(self.call('sales_order.cancel', [order_increment_id]))
120120

121121

122+
class CreditMemo(API):
123+
"""
124+
Allows create/export order credit memos.
125+
"""
126+
__slots__ = ()
127+
128+
def list(self, filters=None):
129+
"""
130+
Retrieve credit memo list by filters
131+
132+
:param filters: Dictionary of filters.
133+
134+
Format :
135+
`{<attribute>:{<operator>:<value>}}`
136+
Example :
137+
`{'firstname':{'ilike':'sharoon'}}`
138+
139+
:return: `list` of `dict`
140+
"""
141+
return self.call('sales_order_creditmemo.list', [filters])
142+
143+
def info(self, creditmemo_increment_id):
144+
"""
145+
Retrieve credit memo info
146+
147+
:param creditmemo_increment_id: Credit memo increment ID
148+
149+
:return dict, credit memo data
150+
"""
151+
return self.call('sales_order_creditmemo.info', [creditmemo_increment_id])
152+
153+
def create(
154+
self,
155+
order_increment_id,
156+
creditmemo_data=None,
157+
comment=None,
158+
email=False,
159+
include_comment=False,
160+
refund_to_store_credit_amount=None):
161+
"""
162+
Create new credit_memo for order
163+
164+
:param order_increment_id: Order Increment ID
165+
:type order_increment_id: str
166+
:param creditmemo_data: Sales order credit memo data (optional)
167+
:type creditmemo_data: associative array as dict
168+
169+
{
170+
'qtys': [
171+
{
172+
'order_item_id': str, # Order item ID to be refunded
173+
'qty': int # Items quantity to be refunded
174+
},
175+
...
176+
],
177+
'shipping_amount': float # refund shipping amount (optional)
178+
'adjustment_positive': float # adjustment refund amount (optional)
179+
'adjustment_negative': float # adjustment fee amount (optional)
180+
}
181+
182+
:param comment: Credit memo Comment
183+
:type comment: str
184+
:param email: send e-mail flag (optional)
185+
:type email: bool
186+
:param include_comment: include comment in e-mail flag (optional)
187+
:type include_comment: bool
188+
:param refund_to_store_credit_amount: amount to refund to store credit
189+
:type refund_to_store_credit_amount: float
190+
191+
:return str, increment id of credit memo created
192+
"""
193+
if comment is None:
194+
comment = ''
195+
return self.call(
196+
'sales_order_creditmemo.create', [
197+
order_increment_id, creditmemo_data, comment, email, include_comment, refund_to_store_credit_amount
198+
]
199+
)
200+
201+
def addcomment(self, creditmemo_increment_id,
202+
comment, email=True, include_in_email=False):
203+
"""
204+
Add new comment to credit memo
205+
206+
:param creditmemo_increment_id: Credit memo increment ID
207+
208+
:return: bool
209+
"""
210+
return bool(
211+
self.call(
212+
'sales_order_creditmemo.addComment',
213+
[creditmemo_increment_id, comment, email, include_in_email]
214+
)
215+
)
216+
217+
#: A proxy for :meth:`addcomment`
218+
addComment = addcomment
219+
220+
def cancel(self, creditmemo_increment_id):
221+
"""
222+
Cancel credit memo
223+
224+
:param creditmemo_increment_id: Credit memo ID
225+
226+
:return: bool
227+
"""
228+
return bool(
229+
self.call('sales_order_creditmemo.cancel', [creditmemo_increment_id])
230+
)
231+
232+
122233
class Shipment(API):
123234
"""
124235
Allows create/export order shipments.

magento/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
installing the module
77
88
"""
9-
VERSION = '2.1'
9+
VERSION = '2.2'

0 commit comments

Comments
 (0)