Compare commits
7 Commits
9ad4da8fe0
...
feat/odoo-
| Author | SHA1 | Date | |
|---|---|---|---|
| d0bc8e49fc | |||
| 84d79b38dd | |||
| 2ebbbdf941 | |||
| 569b66a623 | |||
| bdaa5394b2 | |||
| eef351fd90 | |||
| 326ba36c43 |
@@ -83,7 +83,7 @@ OC_DOCKER_IMAGE=opencloudeu/opencloud-rolling
|
||||
OC_DOCKER_TAG=
|
||||
# Domain of openCloud, where you can find the frontend.
|
||||
# Defaults to "cloud.opencloud.test"
|
||||
OC_DOMAIN=
|
||||
OC_DOMAIN=cloud.opencloud.test
|
||||
# Demo users should not be created on a production instance,
|
||||
# because their passwords are public. Defaults to "false".
|
||||
# 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.
|
||||
# Leaving it default stores data in docker internal volumes.
|
||||
#RADICALE_DATA_DIR=/your/local/radicale/data
|
||||
|
||||
### borgbackup Settings ###
|
||||
BORG_PASSPHRASE=vivid-garnet-lantern-oxide-sparrow-47-reef
|
||||
PGHOST=postgres
|
||||
15
.gitignore
vendored
15
.gitignore
vendored
@@ -17,15 +17,6 @@
|
||||
/config/traefik/dynamic/*
|
||||
!/config/traefik/dynamic/.gitkeep
|
||||
.DS_Store
|
||||
secrets/caddy_email
|
||||
secrets/opencloud_jwt_secret
|
||||
secrets/opencloud_transfer_secret
|
||||
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
|
||||
secrets
|
||||
Persistent Backup
|
||||
backups/*
|
||||
|
||||
@@ -26,6 +26,7 @@ services:
|
||||
BACKUP_RETENTION_COUNT: ${BKP_RETENTION_COUNT}
|
||||
BACKUP_RETENTION_DAYS: ${BKP_RETENTION_DAYS}
|
||||
TIMEZONE: ${TIMEZONE}
|
||||
APK_MIRROR: ${APK_MIRROR}
|
||||
volumes:
|
||||
- ./backups:/backups
|
||||
- type: volume
|
||||
@@ -50,4 +51,4 @@ services:
|
||||
read_only: true
|
||||
- ./scripts/backup/manage-backups.sh:/manage-backups.sh
|
||||
- ./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"]
|
||||
|
||||
@@ -34,8 +34,10 @@ BORG_PASSPHRASE=your-strong-passphrase
|
||||
2. Initialize the repository (first time only):
|
||||
|
||||
```bash
|
||||
docker compose -f backup/borgmatic.yml run --rm borgmatic \
|
||||
borgmatic init --encryption repokey-blake2
|
||||
docker compose build borgmatic
|
||||
|
||||
docker compose run --rm borgmatic \
|
||||
init --encryption repokey-blake2
|
||||
```
|
||||
|
||||
## Usage
|
||||
@@ -43,36 +45,40 @@ docker compose -f backup/borgmatic.yml run --rm borgmatic \
|
||||
### Run Manual Backup
|
||||
|
||||
```bash
|
||||
docker compose -f backup/borgmatic.yml run --rm borgmatic \
|
||||
borgmatic --stats -v 1
|
||||
docker compose build borgmatic
|
||||
|
||||
docker compose run --rm borgmatic \
|
||||
--stats -v 1
|
||||
```
|
||||
|
||||
### Start Scheduled Backups
|
||||
|
||||
```bash
|
||||
docker compose -f backup/borgmatic.yml up -d
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
### List Archives
|
||||
|
||||
```bash
|
||||
docker compose -f backup/borgmatic.yml run --rm borgmatic \
|
||||
borgmatic list
|
||||
docker compose build borgmatic
|
||||
|
||||
docker compose run --rm borgmatic \
|
||||
list
|
||||
```
|
||||
|
||||
### Restore
|
||||
|
||||
```bash
|
||||
# List files in an archive
|
||||
docker compose -f backup/borgmatic.yml run --rm borgmatic \
|
||||
docker compose run --rm borgmatic \
|
||||
borg list ::archive-name
|
||||
|
||||
# Extract entire archive
|
||||
docker compose -f backup/borgmatic.yml run --rm borgmatic \
|
||||
docker compose run --rm borgmatic \
|
||||
borg extract ::archive-name
|
||||
|
||||
# Extract specific path
|
||||
docker compose -f backup/borgmatic.yml run --rm borgmatic \
|
||||
docker compose run --rm borgmatic \
|
||||
borg extract ::archive-name source/gitea_data
|
||||
```
|
||||
|
||||
@@ -80,7 +86,7 @@ docker compose -f backup/borgmatic.yml run --rm borgmatic \
|
||||
|
||||
```bash
|
||||
# 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
|
||||
|
||||
# Restore to database
|
||||
@@ -90,8 +96,10 @@ docker exec -i postgres pg_restore -U admin -d giteadb -c /path/to/giteadb.dump
|
||||
### Check Repository
|
||||
|
||||
```bash
|
||||
docker compose -f backup/borgmatic.yml run --rm borgmatic \
|
||||
borgmatic check
|
||||
docker compose build borgmatic
|
||||
|
||||
docker compose run --rm borgmatic \
|
||||
check
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
@@ -34,15 +34,10 @@ services:
|
||||
|
||||
volumes:
|
||||
opencloud-config:
|
||||
external: true
|
||||
opencloud-data:
|
||||
external: true
|
||||
gitea_data:
|
||||
external: true
|
||||
odoo-db-data:
|
||||
external: true
|
||||
odoo-config:
|
||||
external: true
|
||||
borg-repo:
|
||||
borgmatic-pgdumps:
|
||||
borgmatic-cache:
|
||||
|
||||
1
odoo/addons/mrp_lot_mix/__init__.py
Normal file
1
odoo/addons/mrp_lot_mix/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
17
odoo/addons/mrp_lot_mix/__manifest__.py
Normal file
17
odoo/addons/mrp_lot_mix/__manifest__.py
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "MRP Lot Mix",
|
||||
"version": "1.0.0",
|
||||
"summary": "Mix multiple source lots into a new lot for the same product",
|
||||
"description": "Adds a Manufacturing operation to consume multiple lots/serials of a product and produce a new lot/serial for the same product.",
|
||||
"category": "Manufacturing",
|
||||
"author": "Automated",
|
||||
"license": "LGPL-3",
|
||||
"depends": ["mrp", "stock"],
|
||||
"data": [
|
||||
"security/ir.model.access.csv",
|
||||
"data/ir_sequence.xml",
|
||||
"views/mrp_lot_mix_views.xml",
|
||||
],
|
||||
"installable": True,
|
||||
"application": False,
|
||||
}
|
||||
BIN
odoo/addons/mrp_lot_mix/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
odoo/addons/mrp_lot_mix/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
10
odoo/addons/mrp_lot_mix/data/ir_sequence.xml
Normal file
10
odoo/addons/mrp_lot_mix/data/ir_sequence.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="seq_mrp_lot_mix" model="ir.sequence">
|
||||
<field name="name">Lot Mix Operation</field>
|
||||
<field name="code">mrp.lot.mix</field>
|
||||
<field name="prefix">MIX/%(year)s/</field>
|
||||
<field name="padding">5</field>
|
||||
<field name="company_id" eval="False"/>
|
||||
</record>
|
||||
</odoo>
|
||||
1
odoo/addons/mrp_lot_mix/models/__init__.py
Normal file
1
odoo/addons/mrp_lot_mix/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import mrp_lot_mix
|
||||
Binary file not shown.
Binary file not shown.
360
odoo/addons/mrp_lot_mix/models/mrp_lot_mix.py
Normal file
360
odoo/addons/mrp_lot_mix/models/mrp_lot_mix.py
Normal file
@@ -0,0 +1,360 @@
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
|
||||
|
||||
class MrpLotMix(models.Model):
|
||||
_name = "mrp.lot.mix"
|
||||
_description = "Lot Mix Operation"
|
||||
_order = "id desc"
|
||||
|
||||
name = fields.Char(default="New", readonly=True, copy=False)
|
||||
date = fields.Datetime(default=fields.Datetime.now, required=True)
|
||||
state = fields.Selection(
|
||||
[("draft", "Draft"), ("done", "Done"), ("cancel", "Cancelled")],
|
||||
default="draft",
|
||||
required=True,
|
||||
)
|
||||
company_id = fields.Many2one(
|
||||
"res.company", default=lambda self: self.env.company, required=True
|
||||
)
|
||||
|
||||
product_id = fields.Many2one("product.product", required=True)
|
||||
uom_id = fields.Many2one("uom.uom", related="product_id.uom_id", store=True)
|
||||
source_location_id = fields.Many2one(
|
||||
"stock.location",
|
||||
required=True,
|
||||
domain="[('usage', '=', 'internal')]",
|
||||
)
|
||||
destination_location_id = fields.Many2one(
|
||||
"stock.location",
|
||||
required=True,
|
||||
domain="[('usage', '=', 'internal')]",
|
||||
)
|
||||
|
||||
source_line_ids = fields.One2many(
|
||||
"mrp.lot.mix.line", "mix_id", string="Components", copy=True
|
||||
)
|
||||
allowed_lot_ids = fields.Many2many(
|
||||
"stock.lot",
|
||||
compute="_compute_allowed_lot_ids",
|
||||
string="Available Component Lots",
|
||||
)
|
||||
destination_lot_id = fields.Many2one(
|
||||
"stock.lot",
|
||||
required=True,
|
||||
domain="[('product_id', '=', product_id), '|', ('company_id', '=', False), ('company_id', '=', company_id)]",
|
||||
)
|
||||
|
||||
total_qty = fields.Float(compute="_compute_total_qty", store=True)
|
||||
production_id = fields.Many2one("mrp.production", readonly=True, copy=False)
|
||||
note = fields.Text()
|
||||
|
||||
@api.depends("source_line_ids.quantity")
|
||||
def _compute_total_qty(self):
|
||||
for rec in self:
|
||||
rec.total_qty = sum(rec.source_line_ids.mapped("quantity"))
|
||||
|
||||
@api.depends("product_id", "source_location_id", "company_id")
|
||||
def _compute_allowed_lot_ids(self):
|
||||
quant_obj = self.env["stock.quant"]
|
||||
for rec in self:
|
||||
rec.allowed_lot_ids = False
|
||||
if not rec.product_id or not rec.source_location_id:
|
||||
continue
|
||||
|
||||
quants = quant_obj.search(
|
||||
[
|
||||
("product_id", "=", rec.product_id.id),
|
||||
("location_id", "child_of", rec.source_location_id.id),
|
||||
("quantity", ">", 0),
|
||||
("lot_id", "!=", False),
|
||||
]
|
||||
)
|
||||
lots = quants.mapped("lot_id")
|
||||
if rec.company_id:
|
||||
lots = lots.filtered(
|
||||
lambda lot: not lot.company_id or lot.company_id == rec.company_id
|
||||
)
|
||||
rec.allowed_lot_ids = lots
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
for vals in vals_list:
|
||||
if vals.get("name", "New") == "New":
|
||||
vals["name"] = (
|
||||
self.env["ir.sequence"].next_by_code("mrp.lot.mix") or "New"
|
||||
)
|
||||
return super().create(vals_list)
|
||||
|
||||
@api.onchange("product_id")
|
||||
def _onchange_product_id(self):
|
||||
if not self.product_id:
|
||||
return
|
||||
if self.product_id.tracking == "none":
|
||||
raise UserError(
|
||||
_("Selected product is not lot/serial tracked. Enable tracking first.")
|
||||
)
|
||||
for line in self.source_line_ids:
|
||||
line.lot_id = False
|
||||
|
||||
@api.constrains("source_line_ids")
|
||||
def _check_source_lot_count(self):
|
||||
for rec in self:
|
||||
if rec.state == "draft" and rec.source_line_ids:
|
||||
lot_ids = rec.source_line_ids.filtered("lot_id").mapped("lot_id").ids
|
||||
unique_lots = set(lot_ids)
|
||||
if len(unique_lots) < 2:
|
||||
raise ValidationError(
|
||||
_("Add at least 2 different source lots/serial numbers.")
|
||||
)
|
||||
|
||||
@api.constrains("destination_lot_id", "source_line_ids")
|
||||
def _check_destination_not_in_sources(self):
|
||||
for rec in self:
|
||||
if not rec.destination_lot_id:
|
||||
continue
|
||||
if rec.destination_lot_id in rec.source_line_ids.mapped("lot_id"):
|
||||
raise ValidationError(
|
||||
_("Destination lot/serial must be different from source lots.")
|
||||
)
|
||||
|
||||
def action_cancel(self):
|
||||
for rec in self:
|
||||
if rec.state == "done":
|
||||
raise UserError(_("Done operation cannot be cancelled."))
|
||||
rec.state = "cancel"
|
||||
|
||||
def action_set_draft(self):
|
||||
for rec in self:
|
||||
if rec.state == "done":
|
||||
raise UserError(_("Done operation cannot be reset to draft."))
|
||||
rec.state = "draft"
|
||||
|
||||
def action_confirm_mix(self):
|
||||
for rec in self:
|
||||
rec._run_mix()
|
||||
return True
|
||||
|
||||
def _get_mrp_picking_type(self):
|
||||
self.ensure_one()
|
||||
picking_type = self.env["stock.picking.type"].search(
|
||||
[
|
||||
("code", "=", "mrp_operation"),
|
||||
"|",
|
||||
("company_id", "=", self.company_id.id),
|
||||
("company_id", "=", False),
|
||||
],
|
||||
limit=1,
|
||||
)
|
||||
if not picking_type:
|
||||
raise UserError(
|
||||
_("No Manufacturing Operation Type found for this company.")
|
||||
)
|
||||
return picking_type
|
||||
|
||||
def _run_mix(self):
|
||||
self.ensure_one()
|
||||
|
||||
if self.state != "draft":
|
||||
raise UserError(_("Only draft operations can be confirmed."))
|
||||
if not self.source_line_ids:
|
||||
raise UserError(_("Please add source lots/serials and quantities."))
|
||||
if self.total_qty <= 0:
|
||||
raise UserError(_("Total quantity must be greater than zero."))
|
||||
|
||||
if self.product_id.tracking == "none":
|
||||
raise UserError(
|
||||
_("Selected product is not lot/serial tracked. Enable tracking first.")
|
||||
)
|
||||
if self.product_id.tracking == "serial" and self.total_qty != 1:
|
||||
raise UserError(
|
||||
_(
|
||||
"For serial-tracked products, output quantity must be exactly 1 and use one destination serial number."
|
||||
)
|
||||
)
|
||||
|
||||
if self.product_id.tracking == "serial":
|
||||
invalid_serial_lines = self.source_line_ids.filtered(
|
||||
lambda l: l.quantity != 1
|
||||
)
|
||||
if invalid_serial_lines:
|
||||
raise UserError(
|
||||
_(
|
||||
"For serial-tracked products, each component serial line quantity must be exactly 1."
|
||||
)
|
||||
)
|
||||
|
||||
picking_type = self._get_mrp_picking_type()
|
||||
|
||||
production = self.env["mrp.production"].create(
|
||||
{
|
||||
"origin": self.name,
|
||||
"company_id": self.company_id.id,
|
||||
"product_id": self.product_id.id,
|
||||
"product_uom_id": self.uom_id.id,
|
||||
"product_qty": self.total_qty,
|
||||
"location_src_id": self.source_location_id.id,
|
||||
"location_dest_id": self.destination_location_id.id,
|
||||
"picking_type_id": picking_type.id,
|
||||
}
|
||||
)
|
||||
|
||||
production.action_confirm()
|
||||
|
||||
# Keep the generated finished move to preserve default MRP locations and routes.
|
||||
finished_move = production.move_finished_ids.filtered(
|
||||
lambda m: m.product_id == self.product_id
|
||||
)[:1]
|
||||
if not finished_move:
|
||||
raise UserError(
|
||||
_("Could not find generated finished move for this production order.")
|
||||
)
|
||||
|
||||
finished_move.product_uom_qty = self.total_qty
|
||||
production_location = finished_move.location_id
|
||||
finished_move.move_line_ids.unlink()
|
||||
|
||||
# Remove automatically generated raw moves, then inject one raw move per source lot line.
|
||||
production.move_raw_ids.unlink()
|
||||
stock_move_obj = self.env["stock.move"]
|
||||
stock_move_line_obj = self.env["stock.move.line"]
|
||||
|
||||
for line in self.source_line_ids:
|
||||
raw_move = stock_move_obj.create(
|
||||
{
|
||||
"reference": self.name,
|
||||
"description_picking": _("Consume for lot mix %s") % self.name,
|
||||
"company_id": self.company_id.id,
|
||||
"product_id": self.product_id.id,
|
||||
"product_uom": self.uom_id.id,
|
||||
"product_uom_qty": line.quantity,
|
||||
"location_id": self.source_location_id.id,
|
||||
"location_dest_id": production_location.id,
|
||||
"raw_material_production_id": production.id,
|
||||
}
|
||||
)
|
||||
raw_move = raw_move._action_confirm()[:1]
|
||||
if not raw_move:
|
||||
raise UserError(
|
||||
_("Could not confirm a raw material move for lot mix %s.")
|
||||
% self.name
|
||||
)
|
||||
raw_move.move_line_ids.unlink()
|
||||
stock_move_line_obj.create(
|
||||
{
|
||||
"company_id": self.company_id.id,
|
||||
"move_id": raw_move.id,
|
||||
"product_id": self.product_id.id,
|
||||
"product_uom_id": self.uom_id.id,
|
||||
"quantity": line.quantity,
|
||||
"lot_id": line.lot_id.id,
|
||||
"location_id": self.source_location_id.id,
|
||||
"location_dest_id": production_location.id,
|
||||
}
|
||||
)
|
||||
|
||||
stock_move_line_obj.create(
|
||||
{
|
||||
"company_id": self.company_id.id,
|
||||
"move_id": finished_move.id,
|
||||
"product_id": self.product_id.id,
|
||||
"product_uom_id": self.uom_id.id,
|
||||
"quantity": self.total_qty,
|
||||
"lot_id": self.destination_lot_id.id,
|
||||
"location_id": production_location.id,
|
||||
"location_dest_id": self.destination_location_id.id,
|
||||
}
|
||||
)
|
||||
|
||||
production_write_vals = {}
|
||||
if "lot_producing_id" in production._fields:
|
||||
production_write_vals["lot_producing_id"] = self.destination_lot_id.id
|
||||
if "qty_producing" in production._fields:
|
||||
production_write_vals["qty_producing"] = self.total_qty
|
||||
if production_write_vals:
|
||||
production.write(production_write_vals)
|
||||
|
||||
production.button_mark_done()
|
||||
|
||||
self.write(
|
||||
{
|
||||
"state": "done",
|
||||
"production_id": production.id,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class MrpLotMixLine(models.Model):
|
||||
_name = "mrp.lot.mix.line"
|
||||
_description = "Lot Mix Component Line"
|
||||
|
||||
mix_id = fields.Many2one("mrp.lot.mix", required=True, ondelete="cascade")
|
||||
company_id = fields.Many2one(related="mix_id.company_id", store=True)
|
||||
product_id = fields.Many2one(related="mix_id.product_id", store=True)
|
||||
lot_id = fields.Many2one(
|
||||
"stock.lot",
|
||||
string="Component Lot/Serial",
|
||||
required=True,
|
||||
domain="[('product_id', '=', product_id), '|', ('company_id', '=', False), ('company_id', '=', company_id)]",
|
||||
)
|
||||
quantity = fields.Float(string="Component Quantity", required=True, default=1.0)
|
||||
available_qty = fields.Float(
|
||||
string="Available Quantity", compute="_compute_available_qty"
|
||||
)
|
||||
|
||||
def _get_component_lot_domain(self):
|
||||
self.ensure_one()
|
||||
if not self.product_id or not self.mix_id.source_location_id:
|
||||
return [("id", "=", False)]
|
||||
|
||||
quants = self.env["stock.quant"].search(
|
||||
[
|
||||
("product_id", "=", self.product_id.id),
|
||||
("location_id", "child_of", self.mix_id.source_location_id.id),
|
||||
("quantity", ">", 0),
|
||||
("lot_id", "!=", False),
|
||||
]
|
||||
)
|
||||
lots = quants.mapped("lot_id")
|
||||
if self.company_id:
|
||||
lots = lots.filtered(
|
||||
lambda lot: not lot.company_id or lot.company_id == self.company_id
|
||||
)
|
||||
return [("id", "in", lots.ids)]
|
||||
|
||||
@api.onchange("mix_id", "product_id", "mix_id.source_location_id")
|
||||
def _onchange_component_lot_domain(self):
|
||||
domain = self._get_component_lot_domain()
|
||||
if self.lot_id and not self.lot_id.search_count(
|
||||
domain + [("id", "=", self.lot_id.id)]
|
||||
):
|
||||
self.lot_id = False
|
||||
return {"domain": {"lot_id": domain}}
|
||||
|
||||
@api.depends("lot_id", "mix_id.source_location_id")
|
||||
def _compute_available_qty(self):
|
||||
quant_obj = self.env["stock.quant"]
|
||||
for line in self:
|
||||
if not line.lot_id or not line.mix_id.source_location_id:
|
||||
line.available_qty = 0.0
|
||||
continue
|
||||
domain = [
|
||||
("product_id", "=", line.product_id.id),
|
||||
("lot_id", "=", line.lot_id.id),
|
||||
("location_id", "child_of", line.mix_id.source_location_id.id),
|
||||
]
|
||||
quants = quant_obj.search(domain)
|
||||
line.available_qty = sum(quants.mapped("quantity"))
|
||||
|
||||
@api.constrains("quantity", "available_qty")
|
||||
def _check_quantity(self):
|
||||
for line in self:
|
||||
if line.quantity <= 0:
|
||||
raise ValidationError(_("Line quantity must be greater than zero."))
|
||||
if line.quantity > line.available_qty:
|
||||
raise ValidationError(
|
||||
_(
|
||||
"Quantity for lot %(lot)s exceeds available stock in source location."
|
||||
)
|
||||
% {"lot": line.lot_id.display_name}
|
||||
)
|
||||
3
odoo/addons/mrp_lot_mix/security/ir.model.access.csv
Normal file
3
odoo/addons/mrp_lot_mix/security/ir.model.access.csv
Normal file
@@ -0,0 +1,3 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_mrp_lot_mix_user,mrp.lot.mix user,model_mrp_lot_mix,mrp.group_mrp_user,1,1,1,1
|
||||
access_mrp_lot_mix_line_user,mrp.lot.mix.line user,model_mrp_lot_mix_line,mrp.group_mrp_user,1,1,1,1
|
||||
|
89
odoo/addons/mrp_lot_mix/views/mrp_lot_mix_views.xml
Normal file
89
odoo/addons/mrp_lot_mix/views/mrp_lot_mix_views.xml
Normal file
@@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="view_mrp_lot_mix_tree" model="ir.ui.view">
|
||||
<field name="name">mrp.lot.mix.tree</field>
|
||||
<field name="model">mrp.lot.mix</field>
|
||||
<field name="arch" type="xml">
|
||||
<list>
|
||||
<field name="name"/>
|
||||
<field name="date"/>
|
||||
<field name="product_id"/>
|
||||
<field name="total_qty"/>
|
||||
<field name="destination_lot_id"/>
|
||||
<field name="state"/>
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_mrp_lot_mix_form" model="ir.ui.view">
|
||||
<field name="name">mrp.lot.mix.form</field>
|
||||
<field name="model">mrp.lot.mix</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Lot Mix">
|
||||
<header>
|
||||
<button name="action_confirm_mix" type="object" string="Confirm Mix" class="btn-primary" invisible="state != 'draft'"/>
|
||||
<button name="action_cancel" type="object" string="Cancel" invisible="state == 'done' or state == 'cancel'"/>
|
||||
<button name="action_set_draft" type="object" string="Reset to Draft" invisible="state != 'cancel'"/>
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,done,cancel"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<group>
|
||||
<group>
|
||||
<field name="name" readonly="1"/>
|
||||
<field name="date"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
<field name="product_id" readonly="state != 'draft'"/>
|
||||
<field name="uom_id" readonly="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="source_location_id" readonly="state != 'draft'"/>
|
||||
<field name="destination_location_id" readonly="state != 'draft'"/>
|
||||
<field name="destination_lot_id" readonly="state != 'draft'"/>
|
||||
<field name="total_qty" readonly="1"/>
|
||||
<field name="production_id" readonly="1"/>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
<notebook>
|
||||
<page string="Components">
|
||||
<field name="source_line_ids" readonly="state != 'draft'">
|
||||
<list editable="bottom">
|
||||
<field name="lot_id"/>
|
||||
<field name="quantity"/>
|
||||
<field name="available_qty" readonly="1"/>
|
||||
</list>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Notes">
|
||||
<field name="note" placeholder="Reason, blending details, quality notes..."/>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_mrp_lot_mix" model="ir.actions.act_window">
|
||||
<field name="name">Lot Mix Operations</field>
|
||||
<field name="res_model">mrp.lot.mix</field>
|
||||
<field name="view_mode">list,form</field>
|
||||
<field name="help" type="html">
|
||||
<p>
|
||||
Create a lot-mix operation to consume multiple source lots/serials and produce a new lot/serial of the same product.
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_mrp_lot_mix_root"
|
||||
name="Lot Mix"
|
||||
parent="mrp.menu_mrp_root"
|
||||
sequence="70"
|
||||
groups="mrp.group_mrp_user"/>
|
||||
|
||||
<menuitem id="menu_mrp_lot_mix"
|
||||
name="Mix Orders"
|
||||
parent="mrp.menu_mrp_manufacturing"
|
||||
action="action_mrp_lot_mix"
|
||||
sequence="10"
|
||||
groups="mrp.group_mrp_user"/>
|
||||
</odoo>
|
||||
@@ -30,4 +30,7 @@ create_role() {
|
||||
create_role "${GITEA_DB_USER}" "${GITEA_DB_PASSWORD}"
|
||||
create_role "${ODOO_DB_USER}" "${ODOO_DB_PASSWORD}"
|
||||
|
||||
echo "Grant database creation privilege to ODOO_DB_USER"
|
||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" -c "ALTER USER \"${ODOO_DB_USER}\" WITH CREATEROLE CREATEDB;"
|
||||
|
||||
echo "[init] create-roles finished"
|
||||
|
||||
Reference in New Issue
Block a user