added ows.user
This commit is contained in:
parent
a608f18b3f
commit
a8aa4798b1
|
|
@ -3,7 +3,7 @@
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'version': '13.0.1.0.0',
|
'version': '13.0.1.0.0',
|
||||||
'summary': 'Erstellt Maschinenfreigaben basierend auf POS-Einweisungsprodukten',
|
'summary': 'Erstellt Maschinenfreigaben basierend auf POS-Einweisungsprodukten',
|
||||||
'depends': ['point_of_sale'],
|
'depends': ['contacts','point_of_sale'],
|
||||||
'author': 'matthias.lotz',
|
'author': 'matthias.lotz',
|
||||||
'category': 'Point of Sale',
|
'category': 'Point of Sale',
|
||||||
'data': [
|
'data': [
|
||||||
|
|
|
||||||
1
install-odoo.sh
Executable file
1
install-odoo.sh
Executable file
|
|
@ -0,0 +1 @@
|
||||||
|
/opt/odoo/odoo/odoo-bin -d hobbyhimmel13_dev -i pos_time_based_products,wk_coupons,pos_coupons,open_workshop --stop-after-init --load-language=de_DE
|
||||||
1
install.sh
Executable file
1
install.sh
Executable file
|
|
@ -0,0 +1 @@
|
||||||
|
/opt/odoo/odoo/odoo-bin -d hobbyhimmel13_dev -i open_workshop --stop-after-init
|
||||||
|
|
@ -9,6 +9,35 @@ _logger.info("✅ ows_models.py geladen")
|
||||||
|
|
||||||
class ResPartner(models.Model):
|
class ResPartner(models.Model):
|
||||||
_inherit = 'res.partner'
|
_inherit = 'res.partner'
|
||||||
|
_logger.info("✅ ows ResPartner geladen")
|
||||||
|
ows_user_id = fields.Many2one(
|
||||||
|
'ows.user',
|
||||||
|
string='OWS Benutzerdaten',
|
||||||
|
compute='_compute_ows_user',
|
||||||
|
inverse='_inverse_ows_user',
|
||||||
|
store=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# ✳️ Related-Felder zur Verwendung im Formular
|
||||||
|
birthday = fields.Date(related='ows_user_id.birthday', readonly=False)
|
||||||
|
rfid_card = fields.Text(related='ows_user_id.rfid_card', readonly=False)
|
||||||
|
security_briefing = fields.Boolean(related='ows_user_id.security_briefing', readonly=False)
|
||||||
|
security_id = fields.Text(related='ows_user_id.security_id', readonly=False)
|
||||||
|
|
||||||
|
def _compute_ows_user(self):
|
||||||
|
for partner in self:
|
||||||
|
partner.ows_user_id = self.env['ows.user'].search(
|
||||||
|
[('partner_id', '=', partner.id)],
|
||||||
|
limit=1
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.model_create_multi
|
||||||
|
def create(self, vals_list):
|
||||||
|
partners = super().create(vals_list)
|
||||||
|
for partner in partners:
|
||||||
|
self.env['ows.user'].create({'partner_id': partner.id})
|
||||||
|
return partners
|
||||||
|
|
||||||
|
|
||||||
machine_access_ids = fields.One2many(
|
machine_access_ids = fields.One2many(
|
||||||
'ows.machine.access',
|
'ows.machine.access',
|
||||||
|
|
@ -16,6 +45,7 @@ class ResPartner(models.Model):
|
||||||
string='Maschinenfreigaben'
|
string='Maschinenfreigaben'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
machine_access_html = fields.Html(
|
machine_access_html = fields.Html(
|
||||||
string="Maschinenfreigaben",
|
string="Maschinenfreigaben",
|
||||||
compute="_compute_machine_access_html",
|
compute="_compute_machine_access_html",
|
||||||
|
|
@ -64,6 +94,71 @@ class ResPartner(models.Model):
|
||||||
html += "</div>"
|
html += "</div>"
|
||||||
partner.machine_access_html = html
|
partner.machine_access_html = html
|
||||||
|
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def migrate_existing_partners(self):
|
||||||
|
"""
|
||||||
|
Erstellt für alle vorhandenen res.partner einen ows.user,
|
||||||
|
wenn noch keiner existiert, und übernimmt alte vvow_* Felder.
|
||||||
|
odoo-bin shell -d deine_datenbank
|
||||||
|
env['res.partner'].migrate_existing_partners()
|
||||||
|
"""
|
||||||
|
migrated = 0
|
||||||
|
skipped = 0
|
||||||
|
|
||||||
|
partners = self.env['res.partner'].search([])
|
||||||
|
for partner in partners:
|
||||||
|
if partner.ows_user_id:
|
||||||
|
skipped += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Werte lesen (werden evtl. durch _inherit hinzugefügt)
|
||||||
|
vals = {
|
||||||
|
'partner_id': partner.id,
|
||||||
|
'birthday': getattr(partner, 'vvow_birthday', False),
|
||||||
|
'rfid_card': getattr(partner, 'vvow_rfid_card', False),
|
||||||
|
'security_briefing': getattr(partner, 'vvow_security_briefing', False),
|
||||||
|
'security_id': getattr(partner, 'vvow_security_id', False),
|
||||||
|
}
|
||||||
|
self.env['ows.user'].create(vals)
|
||||||
|
migrated += 1
|
||||||
|
|
||||||
|
_logger = self.env['ir.logging']
|
||||||
|
_logger.info(f"[OWS Migration] ✅ Migriert: {migrated}, ❌ Übersprungen: {skipped}")
|
||||||
|
|
||||||
|
return {
|
||||||
|
'type': 'ir.actions.client',
|
||||||
|
'tag': 'display_notification',
|
||||||
|
'params': {
|
||||||
|
'title': "Migration abgeschlossen",
|
||||||
|
'message': f"{migrated} Partner migriert, {skipped} übersprungen.",
|
||||||
|
'sticky': False,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class OwsUser(models.Model):
|
||||||
|
_name = 'ows.user'
|
||||||
|
_description = 'OWS: Benutzerdaten'
|
||||||
|
_table = 'ows_user'
|
||||||
|
_logger.info("✅ ows_user geladen")
|
||||||
|
|
||||||
|
partner_id = fields.Many2one(
|
||||||
|
'res.partner',
|
||||||
|
required=True,
|
||||||
|
ondelete='cascade',
|
||||||
|
string='Kontakt'
|
||||||
|
)
|
||||||
|
|
||||||
|
birthday = fields.Date('Geburtstag')
|
||||||
|
rfid_card = fields.Text('RFID Card ID')
|
||||||
|
security_briefing = fields.Boolean('Haftungsausschluss', default=False)
|
||||||
|
security_id = fields.Text('Haftungsausschluss ID')
|
||||||
|
|
||||||
|
_sql_constraints = [
|
||||||
|
('partner_unique', 'unique(partner_id)', 'Jeder Partner darf nur einen OWS-Datensatz haben.')
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class OwsMachineArea(models.Model):
|
class OwsMachineArea(models.Model):
|
||||||
_name = 'ows.machine.area'
|
_name = 'ows.machine.area'
|
||||||
_table = "ows_machine_area"
|
_table = "ows_machine_area"
|
||||||
|
|
@ -88,8 +183,9 @@ class OwsMachine(models.Model):
|
||||||
area_id = fields.Many2one('ows.machine.area', string='Bereich')
|
area_id = fields.Many2one('ows.machine.area', string='Bereich')
|
||||||
|
|
||||||
product_ids = fields.One2many('ows.machine.product', 'machine_id', string="Einweisungsprodukte")
|
product_ids = fields.One2many('ows.machine.product', 'machine_id', string="Einweisungsprodukte")
|
||||||
|
|
||||||
product_names = fields.Char(string="Einweisungsprodukte", compute="_compute_product_names", store=False,)
|
product_names = fields.Char(string="Einweisungsprodukte", compute="_compute_product_names", store=False,)
|
||||||
|
machine_product = fields.Many2one('product.product', string="Nutzungsprodukt", domain="[('available_in_pos', '=', True)]")
|
||||||
|
#machine_product = fields.Many2one('product.product', string="Nutzungsprodukt")
|
||||||
|
|
||||||
@api.depends('product_ids.product_id.name')
|
@api.depends('product_ids.product_id.name')
|
||||||
def _compute_product_names(self):
|
def _compute_product_names(self):
|
||||||
|
|
|
||||||
|
|
@ -3,3 +3,4 @@ access_ows_machine_access_user,ows.machine.access,model_ows_machine_access,base.
|
||||||
access_ows_machine_user,ows.machine,model_ows_machine,base.group_user,1,1,1,1
|
access_ows_machine_user,ows.machine,model_ows_machine,base.group_user,1,1,1,1
|
||||||
access_ows_machine_product_user,ows.machine.product,model_ows_machine_product,base.group_user,1,1,1,1
|
access_ows_machine_product_user,ows.machine.product,model_ows_machine_product,base.group_user,1,1,1,1
|
||||||
access_ows_machine_area,ows.machine.area,model_ows_machine_area,base.group_user,1,1,1,1
|
access_ows_machine_area,ows.machine.area,model_ows_machine_area,base.group_user,1,1,1,1
|
||||||
|
access_ows_user,ows.user,model_ows_machine_area,base.group_user,1,1,1,1
|
||||||
|
|
|
||||||
|
1
update.sh
Executable file
1
update.sh
Executable file
|
|
@ -0,0 +1 @@
|
||||||
|
/opt/odoo/odoo/odoo-bin -d hobbyhimmel13_dev --update=open_workshop --stop-after-init
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="code"/>
|
<field name="code"/>
|
||||||
<field name="area_id" widget="many2one_color"/>
|
<field name="area_id" widget="many2one_color"/>
|
||||||
|
<field name="machine_product" widget="many2one"/>
|
||||||
<field name="product_names"/>
|
<field name="product_names"/>
|
||||||
<field name="active"/>
|
<field name="active"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|
@ -26,8 +27,9 @@
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="code"/>
|
<field name="code"/>
|
||||||
<field name="area_id"/>
|
<field name="area_id"/>
|
||||||
<field name="active"/>
|
<field name="machine_product"/>
|
||||||
<field name="description"/>
|
<field name="description"/>
|
||||||
|
<field name="active"/>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
<!-- Neue Einweisungsprodukte-Tabelle -->
|
<!-- Neue Einweisungsprodukte-Tabelle -->
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<!-- res_partner_view.xml -->
|
<!-- res_partner_view.xml -->
|
||||||
<odoo>
|
<odoo>
|
||||||
|
<!-- Teil 1: Maschinenfreigaben-Tabelle -->
|
||||||
<record id="view_partner_form_inherit_open_workshop" model="ir.ui.view">
|
<record id="view_partner_form_inherit_open_workshop" model="ir.ui.view">
|
||||||
<field name="name">res.partner.form.ows.machine.access</field>
|
<field name="name">res.partner.form.ows.machine.access</field>
|
||||||
<field name="model">res.partner</field>
|
<field name="model">res.partner</field>
|
||||||
|
|
@ -19,4 +20,52 @@
|
||||||
</notebook>
|
</notebook>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<!-- Teil 2: HOBBYHIMMEL Basis (ows_user_id Felder) -->
|
||||||
|
<record id="view_partner_form_inherit_ows_user" model="ir.ui.view">
|
||||||
|
<field name="name">res.partner.form.ows.user</field>
|
||||||
|
<field name="model">res.partner</field>
|
||||||
|
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
|
||||||
|
<!-- Geburtstag direkt unter USt-ID -->
|
||||||
|
<xpath expr="//field[@name='vat']" position="after">
|
||||||
|
<field name="birthday"/>
|
||||||
|
</xpath>
|
||||||
|
|
||||||
|
<!-- Eigene Seite "Basis" nach der Verkaufsseite -->
|
||||||
|
<xpath expr="//page[@name='sales_purchases']" position="after">
|
||||||
|
<page name="ows_basic" string="HOBBYHIMMEL Basis">
|
||||||
|
<group name="container_row_2">
|
||||||
|
<group string="Sicherheit">
|
||||||
|
<field name="security_briefing"/>
|
||||||
|
<field name="security_id"/>
|
||||||
|
</group>
|
||||||
|
<group string="Zugang">
|
||||||
|
<field name="rfid_card"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
</page>
|
||||||
|
</xpath>
|
||||||
|
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
<record id="contacts.action_contacts" model="ir.actions.act_window">
|
||||||
|
<field name="view_mode">tree,kanban,form,activity</field>
|
||||||
|
</record>
|
||||||
|
<record id="contacts.action_contacts_view_kanban" model="ir.actions.act_window.view">
|
||||||
|
<field name="sequence" eval="1"/>
|
||||||
|
</record>
|
||||||
|
<record id="contacts.action_contacts_view_tree" model="ir.actions.act_window.view">
|
||||||
|
<field name="sequence" eval="0"/>
|
||||||
|
<!--tree default_order="create_date desc"/-->
|
||||||
|
</record>
|
||||||
|
<!-- Action to set default view to list view for Contacts
|
||||||
|
<record id="contacts.action_contacts" model="ir.actions.act_window">
|
||||||
|
<field name="name">Contacts</field>
|
||||||
|
<field name="res_model">res.partner</field>
|
||||||
|
<field name="view_mode">tree,kanban,form</field>
|
||||||
|
<field name="view_id" ref="base.view_partner_tree"/>
|
||||||
|
</record>
|
||||||
|
-->
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user