Maschinen Ansicht zeigt nun auch die dazugehörigen Einweisungsprodukte
This commit is contained in:
parent
de95446686
commit
8a6d72fb19
|
|
@ -1,12 +1,21 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# ows_models.py
|
||||
# Part of Odoo Open Workshop
|
||||
|
||||
from odoo import models, fields, api
|
||||
import logging
|
||||
_logger = logging.getLogger(__name__)
|
||||
_logger.info("✅ ows_models.py geladen")
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = 'res.partner'
|
||||
|
||||
machine_access_ids = fields.One2many(
|
||||
'ows.machine.access',
|
||||
'partner_id',
|
||||
string='Maschinenfreigaben'
|
||||
)
|
||||
|
||||
machine_access_html = fields.Html(
|
||||
string="Maschinenfreigaben",
|
||||
compute="_compute_machine_access_html",
|
||||
|
|
@ -80,7 +89,13 @@ class OwsMachine(models.Model):
|
|||
|
||||
product_ids = fields.One2many('ows.machine.product', 'machine_id', string="Einweisungsprodukte")
|
||||
|
||||
product_names = fields.Char(string="Einweisungsprodukte", compute="_compute_product_names", store=False,)
|
||||
|
||||
@api.depends('product_ids.product_id.name')
|
||||
def _compute_product_names(self):
|
||||
for machine in self:
|
||||
names = machine.product_ids.mapped('product_id.name')
|
||||
machine.product_names = ", ".join(names)
|
||||
|
||||
_sql_constraints = [
|
||||
('code_unique', 'unique(code)', 'Maschinencode muss eindeutig sein.')
|
||||
|
|
@ -140,11 +155,4 @@ class OwsMachineProduct(models.Model):
|
|||
product_id = fields.Many2one('product.product', required=True, domain=[('available_in_pos', '=', True)], ondelete='cascade')
|
||||
machine_id = fields.Many2one('ows.machine', required=True, ondelete='cascade')
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = 'res.partner'
|
||||
|
||||
machine_access_ids = fields.One2many(
|
||||
'ows.machine.access',
|
||||
'partner_id',
|
||||
string='Maschinenfreigaben'
|
||||
)
|
||||
|
|
|
|||
|
|
@ -9,13 +9,14 @@
|
|||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
<field name="area_id" widget="many2one_color"/>
|
||||
<field name="product_names"/>
|
||||
<field name="active"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Maschinen Formularansicht -->
|
||||
<record id="view_machine_form" model="ir.ui.view">
|
||||
<record id="view_machine_form" model="ir.ui.view">
|
||||
<field name="name">ows.machine.form</field>
|
||||
<field name="model">ows.machine</field>
|
||||
<field name="arch" type="xml">
|
||||
|
|
@ -28,8 +29,19 @@
|
|||
<field name="active"/>
|
||||
<field name="description"/>
|
||||
</group>
|
||||
|
||||
<!-- Neue Einweisungsprodukte-Tabelle -->
|
||||
<notebook>
|
||||
<page string="Einweisungsprodukte">
|
||||
<field name="product_ids" context="{'default_machine_id': active_id}">
|
||||
<tree editable="bottom">
|
||||
<field name="product_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
</record>
|
||||
</odoo>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user