forked from Yaltik/golem
Fonction de facturation
This commit is contained in:
parent
36058fe141
commit
fdf556a8d8
@ -20,13 +20,13 @@
|
||||
'name': 'GOLEM resources pack invoicing',
|
||||
'summary': 'GOLEM resources pack invoicing',
|
||||
'description': ''' GOLEM resources pack invoicing ''',
|
||||
'version': '10.0.0.0.0',
|
||||
'version': '10.0.0.0.1',
|
||||
'category': 'GOLEM',
|
||||
'author': 'Youssef El Ouahby, Fabien Bourgeois',
|
||||
'license': 'AGPL-3',
|
||||
'application': True,
|
||||
'installable': True,
|
||||
'depends': ['golem_resource_pack', 'account'],
|
||||
'depends': ['golem_resource_pack', 'golem_resource_account'],
|
||||
'data': ['views/golem_resource_pack_views.xml']
|
||||
#'security/ir.model.access.csv']
|
||||
}
|
||||
|
@ -32,13 +32,42 @@ class GolemResourcePack(models.Model):
|
||||
copy=False)
|
||||
invoice_amount_total = fields.Monetary(related='invoice_id.amount_total')
|
||||
currency_id = fields.Many2one(related='invoice_id.currency_id')
|
||||
is_products_set = fields.Boolean(compute="compute_is_products_set")
|
||||
|
||||
@api.multi
|
||||
def compute_is_products_set(self):
|
||||
for pack in self:
|
||||
product_list = list(map(lambda x: x.resource_product_id, pack.reservation_ids))
|
||||
if len(filter(lambda x: x.id == False, product_list)) > 0:
|
||||
pack.is_products_set = False
|
||||
else:
|
||||
pack.is_products_set = True
|
||||
|
||||
@api.multi
|
||||
def create_invoice(self):
|
||||
""" create invoice """
|
||||
pass
|
||||
""" Invoice creation """
|
||||
for pack in self:
|
||||
pack.reservation_ids.check_before_invoicing()
|
||||
inv_obj = self.env['account.invoice']
|
||||
partner_id = pack.partner_id
|
||||
invoice_id = inv_obj.create({
|
||||
'origin': pack.name,
|
||||
'type': 'out_invoice',
|
||||
'reference': False,
|
||||
'account_id': partner_id.property_account_receivable_id.id,
|
||||
'partner_id': partner_id.id
|
||||
})
|
||||
pack.invoice_id = invoice_id.id
|
||||
pack.reservation_ids.create_invoice_line(invoice_id)
|
||||
|
||||
@api.multi
|
||||
def show_invoice(self):
|
||||
""" show invoice """
|
||||
pass
|
||||
""" Redirects to linked invoice """
|
||||
self.ensure_one()
|
||||
pack = self[0]
|
||||
if pack.invoice_id:
|
||||
return {'type': 'ir.actions.act_window',
|
||||
'res_model': 'account.invoice',
|
||||
'res_id': pack.invoice_id.id,
|
||||
'view_mode': 'form',
|
||||
'view_id': self.env.ref('account.invoice_form').id}
|
||||
|
@ -18,6 +18,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<odoo>
|
||||
<data>
|
||||
<!-- Tree -->
|
||||
<record model="ir.ui.view" id="golem_resource_pack_inherit_account_tree">
|
||||
<field name="name">GOLEM Resource Pack Account extention Tree</field>
|
||||
<field name="model">golem.resource.pack</field>
|
||||
<field name="inherit_id" ref="golem_resource_pack.golem_resource_pack_view_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="reservation_count" position="after">
|
||||
<field name="invoice_state" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
<!-- Forms -->
|
||||
<record model="ir.ui.view" id="golem_resource_pack_inherit_account_form">
|
||||
<field name="name">GOLEM Resource Pack Account extention Form</field>
|
||||
@ -26,13 +37,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<field name="arch" type="xml">
|
||||
<button name="state_rejected" position="after">
|
||||
<button name="create_invoice" type="object" string="Create Invoice" class="oe_highlight"
|
||||
attrs="{'invisible': ['|', ('state', '!=', 'validated'), ('invoice_id', '!=', False)]}" />
|
||||
attrs="{'invisible': ['|', ('state', '!=', 'validated'), '|', ('invoice_id', '!=', False), ('is_products_set', '=', False)]}" />
|
||||
<button name="show_invoice" type="object" string="Show invoice" class="oe_highlight"
|
||||
attrs="{'invisible': [('invoice_id', '=', False)]}" />
|
||||
</button>
|
||||
<group name="general" position="after">
|
||||
<group name="invoicing" string="Invoicing"
|
||||
attrs="{'invisible': [('invoice_id', '=', False)]}">
|
||||
<field name="is_products_set" invisible="1"/>
|
||||
<field name="invoice_id" />
|
||||
<field name="invoice_state" />
|
||||
<field name="invoice_amount_total" />
|
||||
|
Loading…
Reference in New Issue
Block a user