forked from Yaltik/golem
[MOV][QUA]Pure quality / renaming
This commit is contained in:
parent
a5c51123f3
commit
9b25450a4a
@ -27,6 +27,6 @@
|
||||
'application': True,
|
||||
'installable': True,
|
||||
'depends': ['golem_resource', 'account'],
|
||||
'data': ['wizard/golem_reservation_invoice.xml',
|
||||
'data': ['wizard/golem_reservation_invoice_views.xml',
|
||||
'views/golem_resource_reservation_views.xml']
|
||||
}
|
||||
|
@ -95,26 +95,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
view_mode="form"
|
||||
view_id="golem_reservation_invoice_wizard_form"
|
||||
multi="True"
|
||||
target="new"
|
||||
/>
|
||||
<act_window id="action_golem_reservation_invoice_editable_wizard"
|
||||
name="Reservations to invoice-edition"
|
||||
res_model="golem.reservation.invoice.wizard"
|
||||
src_model="golem.resource.reservation"
|
||||
view_mode="form"
|
||||
view_id="golem_reservation_invoice_wizard_form_editable"
|
||||
multi="True"
|
||||
target="new"
|
||||
/>
|
||||
|
||||
<!-- Actions -->
|
||||
<!--<act_window id="golem_resource_reservation_action" name="Reservations"
|
||||
res_model="golem.resource.reservation" view_mode="tree,form,calendar" />-->
|
||||
|
||||
<!-- Menus -->
|
||||
<!--<menuitem id="golem_resource_reservation_menu" name="Reservations"
|
||||
parent="golem_resource_menu" action="golem_resource_reservation_action"
|
||||
sequence="20" />-->
|
||||
target="new" />
|
||||
<act_window id="action_golem_reservation_invoice_editable_wizard"
|
||||
name="Reservations to invoice-edition"
|
||||
res_model="golem.reservation.invoice.wizard"
|
||||
src_model="golem.resource.reservation"
|
||||
view_mode="form"
|
||||
view_id="golem_reservation_invoice_wizard_form_editable"
|
||||
multi="True"
|
||||
target="new" />
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
|
@ -26,52 +26,51 @@ class GolemReservationInvoiceWizard(models.TransientModel):
|
||||
""" GOLEM Resource Reservation Invoice Wizard """
|
||||
_name = 'golem.reservation.invoice.wizard'
|
||||
|
||||
reservation_ids = fields.Many2many('golem.resource.reservation',
|
||||
default=lambda self: self._context.get('active_ids', []),
|
||||
string='Reservations to invoice')
|
||||
reservation_ids = fields.Many2many(
|
||||
'golem.resource.reservation', required=True, string='Reservations to invoice',
|
||||
default=lambda self: self._context.get('active_ids', []))
|
||||
|
||||
@api.multi
|
||||
def create_invoices(self):
|
||||
""" Invoice creations """
|
||||
self.ensure_one()
|
||||
if self.reservation_ids:
|
||||
|
||||
inv_obj = self.env['account.invoice']
|
||||
partner_id = self.reservation_ids[0].partner_id
|
||||
product = self.reservation_ids[0].resource_id.product_tmpl_id
|
||||
inv_obj = self.env['account.invoice']
|
||||
partner_id = self.reservation_ids[0].partner_id
|
||||
product = self.reservation_ids[0].resource_id.product_tmpl_id
|
||||
|
||||
if product.id:
|
||||
account_id = product.property_account_income_id.id
|
||||
if not account_id:
|
||||
account_id = product.categ_id.property_account_income_categ_id.id
|
||||
if not account_id:
|
||||
raise UserError(
|
||||
_('There is no income account defined for this product: "%s". \
|
||||
You may have to install a chart of account from Accounting \
|
||||
app, settings menu.') % (product.name,))
|
||||
if product.id:
|
||||
account_id = product.property_account_income_id.id
|
||||
if not account_id:
|
||||
account_id = product.categ_id.property_account_income_categ_id.id
|
||||
if not account_id:
|
||||
raise UserError(
|
||||
_('There is no income account defined for this product: "%s". \
|
||||
You may have to install a chart of account from Accounting \
|
||||
app, settings menu.') % (product.name,))
|
||||
|
||||
lines = []
|
||||
lines = []
|
||||
|
||||
for reservation in self.reservation_ids:
|
||||
product = reservation.resource_id.product_tmpl_id
|
||||
amount = product.standard_price
|
||||
lines.append((0, 0, {
|
||||
'name': reservation.resource_id.name,
|
||||
#'origin': ,
|
||||
'account_id': account_id,
|
||||
'price_unit': amount,
|
||||
'quantity': 1.0,
|
||||
'discount': 0.0,
|
||||
'uom_id': product.uom_id.id,
|
||||
'product_id': product.id,
|
||||
}))
|
||||
invoice = inv_obj.create({
|
||||
'name': self.reservation_ids[-1].name,
|
||||
#'origin': self.application_number,
|
||||
'type': 'out_invoice',
|
||||
'reference': False,
|
||||
'account_id': partner_id.property_account_receivable_id.id,
|
||||
'partner_id': partner_id.id,
|
||||
'invoice_line_ids': lines,
|
||||
})
|
||||
self.reservation_ids.write({'invoice_id': invoice.id})
|
||||
for reservation in self.reservation_ids:
|
||||
product = reservation.resource_id.product_tmpl_id
|
||||
amount = product.standard_price
|
||||
lines.append((0, 0, {
|
||||
'name': reservation.resource_id.name,
|
||||
#'origin': ,
|
||||
'account_id': account_id,
|
||||
'price_unit': amount,
|
||||
'quantity': 1.0,
|
||||
'discount': 0.0,
|
||||
'uom_id': product.uom_id.id,
|
||||
'product_id': product.id,
|
||||
}))
|
||||
invoice = inv_obj.create({
|
||||
'name': self.reservation_ids[-1].name,
|
||||
#'origin': self.application_number,
|
||||
'type': 'out_invoice',
|
||||
'reference': False,
|
||||
'account_id': partner_id.property_account_receivable_id.id,
|
||||
'partner_id': partner_id.id,
|
||||
'invoice_line_ids': lines,
|
||||
})
|
||||
self.reservation_ids.write({'invoice_id': invoice.id})
|
||||
|
@ -19,24 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
|
||||
|
||||
<!-- Trees -->
|
||||
<!--<record model="ir.ui.view" id="golem_resource_reservation_view_tree">
|
||||
<field name="name">GOLEM Resource Reservation Tree</field>
|
||||
<field name="model">golem.resource.reservation</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree>
|
||||
<field name="resource_id" />
|
||||
<field name="date" />
|
||||
<field name="hour_start" widget="float_time" />
|
||||
<field name="hour_stop" widget="float_time" />
|
||||
<field name="partner_id" />
|
||||
<field name="state" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>-->
|
||||
|
||||
<!-- Forms -->
|
||||
<record model="ir.ui.view"
|
||||
id="golem_reservation_invoice_wizard_form_editable">
|
||||
@ -45,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<field name="arch" type="xml">
|
||||
<form string="Reservation to invoice">
|
||||
<group>
|
||||
<field name="reservation_ids" context="{'default_reservation_ids': active_ids}" />
|
||||
<field name="reservation_ids" />
|
||||
</group>
|
||||
<footer>
|
||||
<button name="create_invoices" string="Create Invoices" type="object"
|
||||
@ -62,7 +44,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<field name="model">golem.reservation.invoice.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Reservation to invoice">
|
||||
<label string="Invoices will be created in draft so that you can review them before validation" />
|
||||
<p>
|
||||
<strong>
|
||||
Invoices will be created in draft so that you can review them before validation
|
||||
</strong>
|
||||
</p>
|
||||
<footer>
|
||||
<button name="create_invoices" string="Create Invoices" type="object"
|
||||
class="oe_highlight" />
|
||||
@ -72,8 +58,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
|
||||
</data>
|
||||
</odoo>
|
Loading…
Reference in New Issue
Block a user