Compare commits
2 Commits
Export-MO-
...
84d79b38dd
| Author | SHA1 | Date | |
|---|---|---|---|
| 84d79b38dd | |||
| 2ebbbdf941 |
15
.gitignore
vendored
15
.gitignore
vendored
@@ -17,15 +17,6 @@
|
|||||||
/config/traefik/dynamic/*
|
/config/traefik/dynamic/*
|
||||||
!/config/traefik/dynamic/.gitkeep
|
!/config/traefik/dynamic/.gitkeep
|
||||||
.DS_Store
|
.DS_Store
|
||||||
secrets/caddy_email
|
secrets
|
||||||
secrets/opencloud_jwt_secret
|
Persistent Backup
|
||||||
secrets/opencloud_transfer_secret
|
backups/*
|
||||||
secrets/openproject_secret_key_base
|
|
||||||
secrets/traefik
|
|
||||||
Persistent Backup/2025-11-24_18-10/gitea_data_2025-11-24_18-10.tar.gz
|
|
||||||
Persistent Backup/2025-11-24_18-10/giteadb_2025-11-24_18-10.sql.gz
|
|
||||||
Persistent Backup/2025-11-24_18-10/odoo_2025-11-24_18-10.sql.gz
|
|
||||||
Persistent Backup/2025-11-24_18-10/odoo_config_2025-11-24_18-10.tar.gz
|
|
||||||
Persistent Backup/2025-11-24_18-10/odoo_db_data_2025-11-24_18-10.tar.gz
|
|
||||||
Persistent Backup/2025-11-24_18-10/opencloud_config_2025-11-24_18-10.tar.gz
|
|
||||||
Persistent Backup/2025-11-24_18-10/opencloud_data_2025-11-24_18-10.tar.gz
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ services:
|
|||||||
BACKUP_RETENTION_COUNT: ${BKP_RETENTION_COUNT}
|
BACKUP_RETENTION_COUNT: ${BKP_RETENTION_COUNT}
|
||||||
BACKUP_RETENTION_DAYS: ${BKP_RETENTION_DAYS}
|
BACKUP_RETENTION_DAYS: ${BKP_RETENTION_DAYS}
|
||||||
TIMEZONE: ${TIMEZONE}
|
TIMEZONE: ${TIMEZONE}
|
||||||
|
APK_MIRROR: ${APK_MIRROR}
|
||||||
volumes:
|
volumes:
|
||||||
- ./backups:/backups
|
- ./backups:/backups
|
||||||
- type: volume
|
- type: volume
|
||||||
@@ -50,4 +51,4 @@ services:
|
|||||||
read_only: true
|
read_only: true
|
||||||
- ./scripts/backup/manage-backups.sh:/manage-backups.sh
|
- ./scripts/backup/manage-backups.sh:/manage-backups.sh
|
||||||
- ./scripts/backup/backup-manager.cron:/etc/crontabs/root
|
- ./scripts/backup/backup-manager.cron:/etc/crontabs/root
|
||||||
entrypoint: ["/bin/sh", "-c", "# install bsdtar for xattr-aware archives\napk add --no-cache libarchive-tools attr >/dev/null \n# map host /backups ownership to container backup user\nHOST_UID=$$(stat -c '%u' /backups 2>/dev/null || echo 1000) && HOST_GID=$$(stat -c '%g' /backups 2>/dev/null || echo 1000) && addgroup -g \"$$HOST_GID\" backup 2>/dev/null || true && adduser -D -u \"$$HOST_UID\" -G backup backup 2>/dev/null || true && mkdir -p /var/log /backups && chown -R \"$$HOST_UID\":\"$$HOST_GID\" /var/log /backups 2>/dev/null || true && chmod +x /manage-backups.sh && chown root:root /etc/crontabs/root 2>/dev/null || true && crond -f"]
|
entrypoint: ["/bin/sh", "-c", "# install bsdtar for xattr-aware archives\nif [ -n \"$$APK_MIRROR\" ]; then sed -i \"s|https://dl-cdn.alpinelinux.org|$$APK_MIRROR|g\" /etc/apk/repositories; fi && apk add --no-cache libarchive-tools attr >/dev/null \n# map host /backups ownership to container backup user\nHOST_UID=$$(stat -c '%u' /backups 2>/dev/null || echo 1000) && HOST_GID=$$(stat -c '%g' /backups 2>/dev/null || echo 1000) && addgroup -g \"$$HOST_GID\" backup 2>/dev/null || true && adduser -D -u \"$$HOST_UID\" -G backup backup 2>/dev/null || true && mkdir -p /var/log /backups && chown -R \"$$HOST_UID\":\"$$HOST_GID\" /var/log /backups 2>/dev/null || true && chmod +x /manage-backups.sh && chown root:root /etc/crontabs/root 2>/dev/null || true && crond -f"]
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
from . import controllers
|
|
||||||
from . import models
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "MRP Order XLSX Export",
|
|
||||||
"version": "19.0.1.0.0",
|
|
||||||
"summary": "Export Manufacturing Orders to XLSX",
|
|
||||||
"category": "Manufacturing",
|
|
||||||
"license": "LGPL-3",
|
|
||||||
"depends": ["mrp"],
|
|
||||||
"data": [
|
|
||||||
"views/mrp_production_views.xml",
|
|
||||||
],
|
|
||||||
"installable": True,
|
|
||||||
"application": False,
|
|
||||||
"auto_install": False,
|
|
||||||
}
|
|
||||||
Binary file not shown.
@@ -1 +0,0 @@
|
|||||||
from . import main
|
|
||||||
Binary file not shown.
Binary file not shown.
@@ -1,109 +0,0 @@
|
|||||||
import io
|
|
||||||
|
|
||||||
from odoo import fields, http
|
|
||||||
from odoo.http import request
|
|
||||||
|
|
||||||
|
|
||||||
class MrpOrderXlsxExportController(http.Controller):
|
|
||||||
@http.route(
|
|
||||||
"/mrp/production/<int:production_id>/export_xlsx",
|
|
||||||
type="http",
|
|
||||||
auth="user",
|
|
||||||
methods=["GET"],
|
|
||||||
)
|
|
||||||
def export_mrp_order_xlsx(self, production_id, **kwargs):
|
|
||||||
try:
|
|
||||||
import xlsxwriter
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
from odoo.tools.misc import xlsxwriter
|
|
||||||
except ImportError:
|
|
||||||
return request.make_response(
|
|
||||||
"xlsxwriter library is not available in this Odoo environment.",
|
|
||||||
headers=[("Content-Type", "text/plain; charset=utf-8")],
|
|
||||||
status=500,
|
|
||||||
)
|
|
||||||
|
|
||||||
production = request.env["mrp.production"].browse(production_id).exists()
|
|
||||||
if not production:
|
|
||||||
return request.not_found()
|
|
||||||
|
|
||||||
production.check_access_rights("read")
|
|
||||||
production.check_access_rule("read")
|
|
||||||
|
|
||||||
output = io.BytesIO()
|
|
||||||
workbook = xlsxwriter.Workbook(output, {"in_memory": True})
|
|
||||||
worksheet = workbook.add_worksheet("MO")
|
|
||||||
|
|
||||||
header_fmt = workbook.add_format({"bold": True})
|
|
||||||
date_fmt = workbook.add_format({"num_format": "yyyy-mm-dd"})
|
|
||||||
|
|
||||||
row = 0
|
|
||||||
worksheet.write(row, 0, "Manufacturing Order", header_fmt)
|
|
||||||
worksheet.write(row, 1, production.name or "")
|
|
||||||
row += 1
|
|
||||||
|
|
||||||
worksheet.write(row, 0, "Product", header_fmt)
|
|
||||||
worksheet.write(row, 1, production.product_id.display_name or "")
|
|
||||||
row += 1
|
|
||||||
|
|
||||||
worksheet.write(row, 0, "Quantity", header_fmt)
|
|
||||||
worksheet.write(row, 1, production.product_qty or 0.0)
|
|
||||||
row += 1
|
|
||||||
|
|
||||||
worksheet.write(row, 0, "UoM", header_fmt)
|
|
||||||
worksheet.write(row, 1, production.product_uom_id.name or "")
|
|
||||||
row += 1
|
|
||||||
|
|
||||||
worksheet.write(row, 0, "Planned Date", header_fmt)
|
|
||||||
if production.date_start:
|
|
||||||
dt_start = fields.Datetime.from_string(production.date_start)
|
|
||||||
worksheet.write_datetime(row, 1, dt_start, date_fmt)
|
|
||||||
else:
|
|
||||||
worksheet.write(row, 1, "")
|
|
||||||
row += 1
|
|
||||||
|
|
||||||
worksheet.write(row, 0, "Responsible", header_fmt)
|
|
||||||
worksheet.write(row, 1, production.user_id.name or "")
|
|
||||||
row += 2
|
|
||||||
|
|
||||||
table_headers = [
|
|
||||||
"Component",
|
|
||||||
"Required Qty",
|
|
||||||
"Consumed Qty",
|
|
||||||
"UoM",
|
|
||||||
"Source Location",
|
|
||||||
]
|
|
||||||
for col, title in enumerate(table_headers):
|
|
||||||
worksheet.write(row, col, title, header_fmt)
|
|
||||||
row += 1
|
|
||||||
|
|
||||||
for move in production.move_raw_ids.sorted(key=lambda item: item.id):
|
|
||||||
consumed_qty = getattr(move, "quantity", None)
|
|
||||||
if consumed_qty is None:
|
|
||||||
consumed_qty = getattr(move, "quantity_done", 0.0)
|
|
||||||
worksheet.write(row, 0, move.product_id.display_name or "")
|
|
||||||
worksheet.write(row, 1, move.product_uom_qty or 0.0)
|
|
||||||
worksheet.write(row, 2, consumed_qty or 0.0)
|
|
||||||
worksheet.write(row, 3, move.product_uom.name or "")
|
|
||||||
worksheet.write(row, 4, move.location_id.display_name or "")
|
|
||||||
row += 1
|
|
||||||
|
|
||||||
worksheet.set_column(0, 0, 36)
|
|
||||||
worksheet.set_column(1, 4, 18)
|
|
||||||
|
|
||||||
workbook.close()
|
|
||||||
output.seek(0)
|
|
||||||
|
|
||||||
filename = f"{(production.name or 'MO').replace('/', '-')}.xlsx"
|
|
||||||
headers = [
|
|
||||||
(
|
|
||||||
"Content-Disposition",
|
|
||||||
http.content_disposition(filename),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"Content-Type",
|
|
||||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
||||||
),
|
|
||||||
]
|
|
||||||
return request.make_response(output.read(), headers=headers)
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
from . import mrp_production
|
|
||||||
Binary file not shown.
Binary file not shown.
@@ -1,13 +0,0 @@
|
|||||||
from odoo import models
|
|
||||||
|
|
||||||
|
|
||||||
class MrpProduction(models.Model):
|
|
||||||
_inherit = "mrp.production"
|
|
||||||
|
|
||||||
def action_export_xlsx(self):
|
|
||||||
self.ensure_one()
|
|
||||||
return {
|
|
||||||
"type": "ir.actions.act_url",
|
|
||||||
"url": f"/mrp/production/{self.id}/export_xlsx",
|
|
||||||
"target": "self",
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
<record id="mrp_production_form_xlsx_export" model="ir.ui.view">
|
|
||||||
<field name="name">mrp.production.form.xlsx.export</field>
|
|
||||||
<field name="model">mrp.production</field>
|
|
||||||
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//header" position="inside">
|
|
||||||
<button
|
|
||||||
name="action_export_xlsx"
|
|
||||||
string="Export XLSX"
|
|
||||||
type="object"
|
|
||||||
class="btn-secondary"
|
|
||||||
/>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
</odoo>
|
|
||||||
Reference in New Issue
Block a user