3 Commits

18 changed files with 184 additions and 68 deletions

View File

@@ -83,7 +83,7 @@ OC_DOCKER_IMAGE=opencloudeu/opencloud-rolling
OC_DOCKER_TAG= OC_DOCKER_TAG=
# Domain of openCloud, where you can find the frontend. # Domain of openCloud, where you can find the frontend.
# Defaults to "cloud.opencloud.test" # Defaults to "cloud.opencloud.test"
OC_DOMAIN= OC_DOMAIN=cloud.opencloud.test
# Demo users should not be created on a production instance, # Demo users should not be created on a production instance,
# because their passwords are public. Defaults to "false". # because their passwords are public. Defaults to "false".
# If demo users is set to "true", the following user accounts are created automatically: # If demo users is set to "true", the following user accounts are created automatically:
@@ -310,3 +310,7 @@ KC_DB_PASSWORD=
# This matches the default user inside the container and avoids permission issues when accessing files. # This matches the default user inside the container and avoids permission issues when accessing files.
# Leaving it default stores data in docker internal volumes. # Leaving it default stores data in docker internal volumes.
#RADICALE_DATA_DIR=/your/local/radicale/data #RADICALE_DATA_DIR=/your/local/radicale/data
### borgbackup Settings ###
BORG_PASSPHRASE=vivid-garnet-lantern-oxide-sparrow-47-reef
PGHOST=postgres

View File

@@ -34,8 +34,10 @@ BORG_PASSPHRASE=your-strong-passphrase
2. Initialize the repository (first time only): 2. Initialize the repository (first time only):
```bash ```bash
docker compose -f backup/borgmatic.yml run --rm borgmatic \ docker compose build borgmatic
borgmatic init --encryption repokey-blake2
docker compose run --rm borgmatic \
init --encryption repokey-blake2
``` ```
## Usage ## Usage
@@ -43,36 +45,40 @@ docker compose -f backup/borgmatic.yml run --rm borgmatic \
### Run Manual Backup ### Run Manual Backup
```bash ```bash
docker compose -f backup/borgmatic.yml run --rm borgmatic \ docker compose build borgmatic
borgmatic --stats -v 1
docker compose run --rm borgmatic \
--stats -v 1
``` ```
### Start Scheduled Backups ### Start Scheduled Backups
```bash ```bash
docker compose -f backup/borgmatic.yml up -d docker compose up -d
``` ```
### List Archives ### List Archives
```bash ```bash
docker compose -f backup/borgmatic.yml run --rm borgmatic \ docker compose build borgmatic
borgmatic list
docker compose run --rm borgmatic \
list
``` ```
### Restore ### Restore
```bash ```bash
# List files in an archive # List files in an archive
docker compose -f backup/borgmatic.yml run --rm borgmatic \ docker compose run --rm borgmatic \
borg list ::archive-name borg list ::archive-name
# Extract entire archive # Extract entire archive
docker compose -f backup/borgmatic.yml run --rm borgmatic \ docker compose run --rm borgmatic \
borg extract ::archive-name borg extract ::archive-name
# Extract specific path # Extract specific path
docker compose -f backup/borgmatic.yml run --rm borgmatic \ docker compose run --rm borgmatic \
borg extract ::archive-name source/gitea_data borg extract ::archive-name source/gitea_data
``` ```
@@ -80,7 +86,7 @@ docker compose -f backup/borgmatic.yml run --rm borgmatic \
```bash ```bash
# Extract dump from backup # Extract dump from backup
docker compose -f backup/borgmatic.yml run --rm borgmatic \ docker compose run --rm borgmatic \
borg extract ::archive-name source/pgdumps/giteadb.dump borg extract ::archive-name source/pgdumps/giteadb.dump
# Restore to database # Restore to database
@@ -90,8 +96,10 @@ docker exec -i postgres pg_restore -U admin -d giteadb -c /path/to/giteadb.dump
### Check Repository ### Check Repository
```bash ```bash
docker compose -f backup/borgmatic.yml run --rm borgmatic \ docker compose build borgmatic
borgmatic check
docker compose run --rm borgmatic \
check
``` ```
## Configuration ## Configuration

View File

@@ -34,15 +34,10 @@ services:
volumes: volumes:
opencloud-config: opencloud-config:
external: true
opencloud-data: opencloud-data:
external: true
gitea_data: gitea_data:
external: true
odoo-db-data: odoo-db-data:
external: true
odoo-config: odoo-config:
external: true
borg-repo: borg-repo:
borgmatic-pgdumps: borgmatic-pgdumps:
borgmatic-cache: borgmatic-cache:

View File

@@ -1 +0,0 @@
# -*- coding: utf-8 -*-

View File

@@ -1,21 +0,0 @@
# -*- coding: utf-8 -*-
{
'name': 'Custom Delivery Slip',
'version': '19.0.1.0.0',
'category': 'Inventory',
'summary': 'Customize delivery slip with lot number, production date, expiration date',
'description': """
Adds the following fields to delivery slips:
- Lot/Serial number
- Production date (today's date)
- Expiration date (6 months from production)
- Product name
""",
'depends': ['stock'],
'data': [
'views/report_deliveryslip.xml',
],
'installable': True,
'application': False,
'auto_install': False,
}

View File

@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Inherit the delivery slip report template for completed deliveries (state='done') -->
<template id="stock_report_delivery_has_serial_move_line_custom" inherit_id="stock.stock_report_delivery_has_serial_move_line">
<!-- Add Production Date after lot number -->
<xpath expr="//td[@name='move_line_lot']" position="after">
<td class="text-end">
<span t-esc="datetime.datetime.now().strftime('%Y-%m-%d')"/>
</td>
</xpath>
<!-- Add Expiration Date after Production Date -->
<xpath expr="//td[@name='move_line_lot_quantity']" position="before">
<td class="text-end">
<span t-esc="(datetime.datetime.now() + datetime.timedelta(days=180)).strftime('%Y-%m-%d')"/>
</td>
</xpath>
</template>
<!-- Add column headers for Production and Expiration dates in the main table -->
<template id="report_delivery_document_custom" inherit_id="stock.report_delivery_document">
<!-- Add headers for completed deliveries table -->
<xpath expr="//table[@name='stock_move_line_table']/thead/tr/th[@name='lot_serial']" position="after">
<th name="th_production_date" class="text-end">Production Date</th>
<th name="th_expiration_date" class="text-end">Expiration Date</th>
</xpath>
</template>
</odoo>

View File

@@ -0,0 +1,2 @@
from . import controllers
from . import models

View File

@@ -0,0 +1,14 @@
{
"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,
}

View File

@@ -0,0 +1 @@
from . import main

View File

@@ -0,0 +1,109 @@
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)

View File

@@ -0,0 +1 @@
from . import mrp_production

View File

@@ -0,0 +1,13 @@
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",
}

View File

@@ -0,0 +1,18 @@
<?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>