Skip to Content
Menú
This question has been flagged
3 Respostes
2070 Vistes

Hi everyone and thank you in advance for any assistance. Long time odoo user trying out some module creations. I am trying to create a module to hold data from excel. mass data. unfortunately running into issues and I am worried that it is my build - missing dependencies?
Here is my code can someone tell me where I am going wrong?




manifest.py


# -*- coding: utf-8 -*-

{

    'name': 'Alpha Jobs',

    'version': '1.0',

    'summary': 'Manage Alpha Jobs',

    'sequence': 10,

    'category': 'Uncategorized',

    'depends': ['base','contacts'],

    'data': [

        'security/ir.model.access.csv',

        'views/alpha_jobs_menus.xml',

        'views/alpha_jobs_views.xml',

        'views/alpha_jobs_actions.xml',

    ],

    'demo': [],

    'installable': True,

    'auto_install': False,

    'application': True,

}



---------------


alphajobs.py


from odoo import models, fields, api


class AlphaJobs(models.Model):

    _name = 'alpha.jobs'

    _description = 'Alpha Jobs'

    _rec_name = 'job_id'


    job_id = fields.Char(string='Job ID', compute='_compute_job_id', store=True, readonly=True, index=True)

    job_no = fields.Char('Job Number', required=True)

    sub_job_no = fields.Char('Sub Job Number')

    customer = fields.Many2one('res.partner', string='Customer')

    QUOTE_NO = fields.Char('Quote Number')

    QUOTE_SUB_NO = fields.Char('Quote Sub Number')

    ALCONTACT = fields.Char('Contact')

    ALDATE_OPENED = fields.Integer('Date Opened')

    ALDATE_DUE = fields.Integer('Alpha Date Due')

    DATE_SHIPPED = fields.Integer('Date Shipped')

    JOB_STATUS = fields.Char('Job Status')

    CUSTOMER_PO_NO = fields.Char('Customer PO Number')

    ALCLASS = fields.Char('Class')

    ORIENTATION = fields.Char('Orientation')

    CUSTOMER_PO = fields.Char('Customer PO')

    DWG_NO = fields.Char('Drawing Number')

    ALPART_NAME = fields.Char('Alpha Part Name')

    ALPART_CODE = fields.Char('ALpha Part Code')

    ALQTY = fields.Char('Quantity')

    PART_STATUS = fields.Char('Part Status')

    REQUIREMENT = fields.Char('Requirement')

    ALPRICE = fields.Char('Price(al)')

    ALTOTAL = fields.Char('Total(al)')

    ALTOTAL_GST = fields.Char('Including GST')

    SHIPPING_CHECK = fields.Char('Shipping Check')

    PC_SN = fields.Char('PC SN')

    ALSHIP_DATE = fields.Char('Ship Date')

    ALSHIP_QTY = fields.Char('Shipped Quantity')

    MFG_QTY = fields.Char('Manufactured Quantity')

    BO_QTY = fields.Char('Billed Quantity')

    ALSTOCK_QTY = fields.Char('Stock Quantity')

    JOBJOBID = fields.Char('Job job ID')

    MFG_CHECK = fields.Char('Manufacturing Check')

    ALDUE_DATE = fields.Char('Due Date')

    SHP_INV = fields.Char('Shop Invoice')

    INVOICE_QTY = fields.Char('Invoiced Quantity')

    C_OR_V = fields.Char('C or V')

    INV_NUM = fields.Char('Invoice Number')

    INV_DATE = fields.Char('Date Invoiced')

    INV_DUE_DATE = fields.Char('Inv Due Date')

    CUSTOMER_PO_NUM = fields.Char('Customer PO Number main')

    INV_CUSTOMER = fields.Char('Invoice Customer')

    INVOICELINEDESC = fields.Char('Invoice line Description')

    INVOICELINEQUANTITY = fields.Char('Invoice line Quantity')

    INVOICELINEAMOUNT = fields.Char('Invoice line Amount')

    CUSTOMFIELDBLACKLAWJOBNO = fields.Char('BL Job Number')

    INVGST = fields.Char('Invoice GST')

    II_INDEX = fields.Char('II Index')

    INV_ITEM = fields.Char('Invoice Item')

    PS_NO = fields.Char('PS Number')

    PI_INDEX = fields.Char('PI Index')

    PACKINGSLIP_NO = fields.Char('Packing Slip Number')

    ALITEM = fields.Char('Item')

    AL_QTY = fields.Char('AL Quantity')

    AL_DESCRIPTION = fields.Char('Description')

    WT = fields.Char('Weight')

    PURPOSE_AL = fields.Char('Purpose')

    PRICE_Al = fields.Char('Price al')

    PER_UNITS_AL = fields.Char('Per Units')

    T_WT = fields.Char('Total Weight')

    PART_NO_AL = fields.Char('Part Number')

    EXT_PRICE = fields.Char('Extended Price')

    PO_AL = fields.Char('PO Number')

    PART_NAME = fields.Char('Part Name')

    PI_INDEX = fields.Char('PI Index')

    AL_SN = fields.Char('Serial Number')

    SHIP_TO = fields.Char('Ship to')

    CO = fields.Char('CO')

    CUSTOMER_PO = fields.Char('Customer PO')

    SHIPPED_BY = fields.Char('Shipped by')

    CARRIER_AL = fields.Char('Carrier')

    PAYMENT_TYPE = fields.Char('Payment Type')

    DATE_SHIP_AL = fields.Char('Date Shipped AL')

    DWG_NO = fields.Char('Drawing Number')

    PART_CODE = fields.Char('Part Code')

    PART_NAME1 = fields.Char('Part Name1')

    REQUIREMENT = fields.Char('Requirement')

    QTY_AL = fields.Char('Quantity_AL')

    PRICEA = fields.Char('Price')

    AMOUNT_AL = fields.Char('Amount')

    MARKUP = fields.Char('Markup')

    TOTAL_CHARGE = fields.Char('Total Charge')

    PRICE_CHARGE = fields.Char('Price Charge')

    CHECK = fields.Char('Check')

    FINISH_DATE = fields.Char('Finish Date')

    PC_SN = fields.Char('PC_SN')

    JQJ_INDEX = fields.Char('JQJ_INDEX')

    DATE_OPENED = fields.Char('Job Date Opened')

    QUOTE_STS = fields.Char('Quote STS')

    ATTENTION = fields.Char('Attention')

    ATTEN_ID = fields.Char('Attention ID')

    SHIP_VIA = fields.Char('Ship Via')

    FOB = fields.Char('FOB')

    TERMS = fields.Char('Terms')

    DAYS = fields.Char('Days')

    CONTACT_AL = fields.Char('Alpha Contact')

    CONTACT_ID = fields.Char('Contact ID')

    REL_QUOTE_NO = fields.Char('Related Quote NO')

    # Link sub-jobs to their parent jobs

    parent_job_id = fields.Many2one('alpha.jobs', string='Parent Job')


    # One2many fields for purchases and employee entries

    purchase_ids = fields.One2many('alpha.purchase', 'job_id', string='Purchases')

    employee_time_ids = fields.One2many('alpha.employee.time', 'job_id', string='Employee Times')


    @api.depends('job_no', 'sub_job_no')

    def _compute_job_id(self):

        for record in self:

            job_id = record.job_no

            if record.sub_job_no:

                job_id += '-' + record.sub_job_no

            record.job_id = job_id


    @api.constrains('job_id')

    def _check_unique_job_id(self):

        for record in self:

            existing_record = self.search([('job_id', '=', record.job_id)])

            if len(existing_record) > 1 or (len(existing_record) == 1 and existing_record != record):

                raise ValidationError("Job ID '%s' already exists. Please choose a unique Job ID." % record.job_id)



class AlphaEmployeeTime(models.Model):

    _name = 'alpha.employee.time'

    _description = 'Alpha Employee Time'


    # Define fields to store employee entries

    job_id = fields.Many2one('alpha.jobs', string='Job')

    Name = fields.Char(string='Employee Name')

    EMDATE = fields.Date('Date of Work')

    EMPLOYEE_DESCRIPTION = fields.Text('Work Description')

    REGULAR_HOURS = fields.Float('Regular Hours')

    EMPLOYEE_ID = fields.Char('Employee ID')

    EMPLOYEE_STATION = fields.Char('Station')

    EMNAME = fields.Char('Name')

    EMPLYEE_OVERTIME = fields.Float('Overtime')

    EMPLOYEE_REG_HRS = fields.Float('Employee Regular Hours')

    TOTAL_STATION_HRS = fields.Float('Total Station Hours')



class AlphaPurchase(models.Model):

    _name = 'alpha.purchase'

    _description = 'Alpha Purchase'


    # Define fields to store purchase information

    job_id = fields.Many2one('alpha.jobs', string='Job')

    POITEM_INDEX = fields.Char(string='PO Item Index')

    POITEM = fields.Char(string='PO Item')

    PORF_NO = fields.Char(string='PO Reference Number')

    VENDOR = fields.Char(string='Vendor')

    PODATE = fields.Date(string='PO Date')

    SHIPPING_TO = fields.Char(string='Shipping to')

    PO_AL = fields.Char(string='PO Number')

    PART_NO_AL = fields.Char(string='Part Number')

    PART_NAME = fields.Char(string='Part Name')

    QTY_AL = fields.Char(string='Quantity')

    PRICEA = fields.Char(string='Price')

    AMOUNT_AL = fields.Char(string='Amount')

    AL_SN = fields.Char(string='Serial Number')

    SHIP_TO = fields.Char(string='Ship to')

    CO = fields.Char(string='CO')

    CUSTOMER_PO = fields.Char(string='Customer PO')

    SHIPPED_BY = fields.Char(string='Shipped by')

    CARRIER_AL = fields.Char(string='Carrier')

    PAYMENT_TYPE = fields.Char(string='Payment Type')

    DATE_SHIP_AL = fields.Char(string='Date Shipped AL')

    DWG_NO = fields.Char(string='Drawing Number')

    PART_CODE = fields.Char(string='Part Code')

    PART_NAME1 = fields.Char(string='Part Name1')

    REQUIREMENT = fields.Char(string='Requirement')

    PRICE_CHARGE = fields.Char(string='Price Charge')

    CHECK = fields.Char(string='Check')

    FINISH_DATE = fields.Char(string='Finish Date')

    PC_SN = fields.Char(string='PC_SN')

    JQJ_INDEX = fields.Char(string='JQJ_INDEX')




---------------


ir.model.access.csv


id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink

access_alpha_jobs,model_alpha_jobs,model_alpha_jobs,base.group_user,1,1,1,1


---------------


alpha_jobs_menus.xml

   

 

   

       

           

           

       

   


---------------


alpha_jobs_views.xml


   


       

       

            Alpha Jobs Tree

            alpha.jobs

            tree,form

            []

       


       

       

            Alpha Jobs Kanban

            alpha.jobs

            kanban,form

            []

       


   




   


---------------


alpha_jobs_actions.xml

   

       

       

            Alpha Jobs

            alpha.jobs

            tree,form,kanban

            []

            {}

           

               

                    Click to create a new record.

               

           

       


       

       

            Alpha Jobs Kanban

            alpha.jobs

            kanban,tree,form

            []

            {}

           

               

                    Click to create a new record.

               

           

       

   


   



Avatar
Descartar
Autor


alpha_jobs_menus.xml

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<menu id="menu_alpha_jobs_root" name="Alpha Jobs" sequence="10">
<menuitem id="menu_alpha_jobs_tree" name="Alpha Jobs Tree" parent="menu_alpha_jobs_root" action="action_alpha_jobs_tree" sequence="10" />
<menuitem id="menu_alpha_jobs_kanban" name="Alpha Jobs Kanban" parent="menu_alpha_jobs_root" action="action_alpha_jobs_kanban" sequence="20" />
</menu>
</odoo>

---------------

alpha_jobs_views.xml

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>

<!-- Action for Tree View -->
<record id="action_alpha_jobs_tree" model="ir.actions.act_window">
<field name="name">Alpha Jobs Tree</field>
<field name="res_model">alpha.jobs</field>
<field name="view_mode">tree,form</field>
<field name="domain">[]</field>
</record>

<!-- Action for Kanban View -->
<record id="action_alpha_jobs_kanban" model="ir.actions.act_window">
<field name="name">Alpha Jobs Kanban</field>
<field name="res_model">alpha.jobs</field>
<field name="view_mode">kanban,form</field>
<field name="domain">[]</field>
</record>

</data>
</odoo>

---------------

alpha_jobs_actions.xml

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- Action for Tree View -->
<record id="action_alpha_jobs_tree" model="ir.actions.act_window">
<field name="name">Alpha Jobs</field>
<field name="res_model">alpha.jobs</field>
<field name="view_mode">tree,form,kanban</field>
<field name="domain">[]</field>
<field name="context">{}</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a new record.
</p>
</field>
</record>

<!-- Action for Kanban View -->
<record id="action_alpha_jobs_kanban" model="ir.actions.act_window">
<field name="name">Alpha Jobs Kanban</field>
<field name="res_model">alpha.jobs</field>
<field name="view_mode">kanban,tree,form</field>
<field name="domain">[]</field>
<field name="context">{}</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a new record.
</p>
</field>
</record>
</data>
</odoo>

won't let me edit my original post

Best Answer

Hello.


I've never seen and tried your code before in terms of creating menus in Odoo.

I think you should try to remove the menu tag and don't forget to the end tag.


   

 



try this instead.


<?xml version="1.0" encoding="utf-8"?>

<odoo>

<menuitem id="menu_alpha_jobs_root" name="Alpha Jobs" sequence="10"/>

/cp<menuitem id="menu_alpha_jobs_tree" name="Alpha Jobs Tree" parent="menu_alpha_jobs_root" action="action_alpha_jobs_tree" sequence="10" />

<menuitem id="menu_alpha_jobs_kanban" name="Alpha Jobs Kanban" parent="menu_alpha_jobs_root" action="action_alpha_jobs_kanban" sequence="20" />

</odoo>



menu_alpha_jobs_root is your main menu or root menu, the parent of your menu (Alpha Jobs Tree and Alpha Jobs Kanban)

instead of menu tag make it menuitem

like menuitem id="menu_alpha_jobs_root" 




Avatar
Descartar
Autor

Thank you I will try this. will mark as solved if it works.

Autor

ParseError('while parsing %s:%s, somewhere inside\n%s' % (
views/alpha_jobs_menus.xml:5, somewhere inside
<menuitem id="menu_alpha_jobs_tree" name="Alpha Jobs Tree" parent="menu_alpha_jobs_root" action="action_alpha_jobs_tree" sequence="10"/>

in reviewing my code it is all wrong...
going to have to rebuild my views I think.
Can anyone link me to a proper view example for tree form and kanban v17. thanks in advance

ParseError('while parsing %s:%s, somewhere inside\n%s' % (
views/alpha_jobs_menus.xml:5, somewhere inside
<menuitem id="menu_alpha_jobs_tree" name="Alpha Jobs Tree" parent="menu_alpha_jobs_root" action="action_alpha_jobs_tree" sequence="10"/>

I think the error shows because in my given xml code it has extra letters "/cp" before the <menuitem id="menu_alpha_jobs_tree" ~ remove it, don't copy and paste all my code.

<?xml version="1.0" encoding="utf-8"?>

<odoo>

<menuitem id="menu_alpha_jobs_root" name="Alpha Jobs" sequence="10"/>

<menuitem id="menu_alpha_jobs_tree" name="Alpha Jobs Tree" parent="menu_alpha_jobs_root" action="action_alpha_jobs_tree" sequence="10" />

<menuitem id="menu_alpha_jobs_kanban" name="Alpha Jobs Kanban" parent="menu_alpha_jobs_root" action="action_alpha_jobs_kanban" sequence="20" />

</odoo>

try this.

Autor

I actually removed that when trying your code. still parse error.

Autor Best Answer

thank you for the reply.

The module installs - up to views and menus

Log error

views/alpha_jobs_menus.xml' does not fit the required schema!

AssertionError: Element odoo has extra content: menu, line 3 


Problem is no matter what I do to change this, removed

changed to , even changed the menu and view structure and load sequence in manifest. will not install the menus/views
Avatar
Descartar

the error saying that the file alpha_jobs_menus is not written in proper xml syntax

Autor

alpha_jobs_menus.xml

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<menu id="menu_alpha_jobs_root" name="Alpha Jobs" sequence="10">
<menuitem id="menu_alpha_jobs_tree" name="Alpha Jobs Tree" parent="menu_alpha_jobs_root" action="action_alpha_jobs_tree" sequence="10" />
<menuitem id="menu_alpha_jobs_kanban" name="Alpha Jobs Kanban" parent="menu_alpha_jobs_root" action="action_alpha_jobs_kanban" sequence="20" />
</menu>
</odoo>

indentation is proper in the .xml. I have used this menu structure previous. never with v17
should it be different?

Best Answer

Hi,
Along with the post try adding the information regarding the issue ? Is it getting installed ? Any exceptions are raised ? such information is missing.

So answering generically, you can refer to this tutorial:  Odoo 17 Development Tutorials

Thanks

Avatar
Descartar
Related Posts Respostes Vistes Activitat
3
de des. 23
4392
1
de març 15
5739
2
de març 15
6932
3
de jul. 25
1159
1
de jul. 24
4011