Skip to content

Commit

Permalink
Added increments for invoice
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengfeng-toh committed Dec 25, 2023
1 parent defb1b8 commit 688c6f8
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 43 deletions.
11 changes: 10 additions & 1 deletion local-addons/morons/models/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,19 @@ class Invoice(models.Model):
("invoiced", "Invoiced"),
("paid", "Paid"),
]

invoice_id = fields.Char(string='Invoice ID', required=True, copy=False, readonly=True, index=True, default=lambda self: 'New')

@api.model
def create(self, vals):
if vals.get('invoice_id', 'New') == 'New':
vals['invoice_id'] = self.env['ir.sequence'].next_by_code('morons.invoice') or 'New'
result = super(Invoice, self).create(vals)
return result

issue_date = fields.Date(string='Issue Date')
due_date = fields.Date(string='Due Date')
sender = fields.Char(string='Issued By')
sender = fields.Many2one('res.user',string='Issued By')

purchase_order = fields.Many2one('project.task', string='Purchase Order')

Expand Down
91 changes: 49 additions & 42 deletions local-addons/morons/views/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,49 +192,69 @@
<field name="domain">[('share', '=', False)]</field>
</record>

<!-- INCREMENT INVOICE ID -->
<record id="seq_morons_invoice" model="ir.sequence">
<field name="name">Morons Invoice</field>
<field name="code">morons.invoice</field>
<field name="prefix">INV-</field>
<field name="padding">5</field>
<field name="number_increment">1</field>
</record>

<!-- INVOICE FORM VIEW -->
<record id="morons.morons_invoice_form" model="ir.ui.view">
<field name="name">morons list</field>
<field name="model">morons.invoice</field>
<field name="arch" type="xml">
<form>
<group>
<field name="issue_date"/>
<field name="due_date"/>
<field name="sender"/>
<field name="purchase_order"/>
<field name="note"/>
<field name="currency"/>
<field name="work_unit"/>
<field name="rate"/>
<field name="sale_unit"/>
<field name="payable"/>
<field name="payable_usd"/>
<field name="status" groups="base.group_system,morons.group_pm,morons.group_bod,morons.group_accountants"/>
</group>
</form>
<sheet>
<form>
<group>
<group col="3">
<field name="invoice_id" readonly="1"/>
<field name="issue_date"/>
<field name="due_date"/>
<field name="sender"/>
<field name="purchase_order"/>
<field name="note"/>
</group>
<group col="3">
<field name="currency"/>
<field name="work_unit"/>
<field name="rate"/>
<field name="sale_unit"/>
<field name="payable"/>
<field name="payable_usd"/>
<field name="status" groups="base.group_system,morons.group_pm,morons.group_bod,morons.group_accountants"/>
</group>
</group>
</form>
</sheet>
</field>
</record>

<!-- VIEW ALL INVOICES LIST -->
<record id="morons.morons_invoice_tree" model="ir.ui.view">
<field name="name">morons list</field>
<field name="model">morons.invoice</field>
<field name="arch" type="xml">
<tree>
<field name="issue_date"/>
<field name="due_date"/>
<field name="sender"/>
<field name="note"/>
<field name="currency"/>
<field name="work_unit"/>
<field name="rate"/>
<field name="sale_unit"/>
<field name="payable"/>
<field name="payable_usd"/>
<field name="status"/>
</tree>
<field name="invoice_id" readonly="1"/>
<field name="issue_date"/>
<field name="due_date"/>
<field name="sender"/>
<field name="note"/>
<field name="currency"/>
<field name="work_unit"/>
<field name="rate"/>
<field name="sale_unit"/>
<field name="payable"/>
<field name="payable_usd"/>
<field name="status"/>
</tree>
</field>
</record>

<!-- IR.ACTION TO OPEN INVOICE LIST VIEW -->
<record id="action_open_invoice" model="ir.actions.act_window">
<field name="name">Invoices</field>
<field name="res_model">morons.invoice</field>
Expand All @@ -248,9 +268,7 @@
<menuitem id="menu_morons_invoice"
name="Invoices"
parent="project.menu_main_pm"
action="action_open_invoice"
groups="base.group_system"/>

action="action_open_invoice"/>

<!-- CREATION OF INTERNAL USER NAVBAR OPTION -->
<menuitem id="menu_res_users"
Expand All @@ -259,17 +277,6 @@
action="action_open_res_users"
groups="base.group_system"/>



<!-- INVOICE VIEW -->

<!-- CREATION OF INTERNAL USER NAVBAR OPTION -->
<!-- <menuitem id="menu_res_invoice"
name="Invoices"
parent="project.menu_main_pm"
action="action_open_invoice"
groups="base.group_system"/> -->

<menuitem id="project.menu_projects"
name="Projects"
parent="project.menu_main_pm"
Expand Down

0 comments on commit 688c6f8

Please sign in to comment.