Commit 58145a69 by François C.

Merge branch '3899-export-orders' into 'dev_cooperatic'

create sql request in purchase module to get orders between 2 dates

See merge request !47
parents fd231727 1dbeeaa8
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
Customization of Purchase process""", Customization of Purchase process""",
'description': """ 'description': """
Customization of Purchase process Customization of Purchase process & orders export method
""", """,
'author': "cooperatic", 'author': "cooperatic",
......
...@@ -40,3 +40,27 @@ class PurchaseOrder(models.Model): ...@@ -40,3 +40,27 @@ class PurchaseOrder(models.Model):
export_url += '/export/' + str(self.id) export_url += '/export/' + str(self.id)
requests.get(export_url) requests.get(export_url)
return res return res
@api.multi
def get_received_orders_between_dates(self, date_from, date_to):
res = {}
sql = """
SELECT po.name as id_po, sp.date_done, po.amount_untaxed, po.amount_total, po.state, rp.name as supplier_name
FROM purchase_order as po
LEFT JOIN stock_picking as sp ON po.name=sp.origin
LEFT JOIN res_partner as rp ON po.partner_id=rp.id
WHERE sp.date_done IS NOT NULL
AND sp.date_done >= '{date_from}'
AND sp.date_done <= '{date_to}'
ORDER BY sp.date_done ASC
"""
sql = sql.format(date_from=date_from, date_to=date_to)
try:
self.env.cr.execute(sql)
res["data"] = self.env.cr.dictfetchall()
except Exception as e:
res["error"] = str(e)
return res
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment