Skip to content

Commit

Permalink
[IMP] pre-commit stuff (#2627)
Browse files Browse the repository at this point in the history
  • Loading branch information
oihane authored and Berezi committed Nov 19, 2024
1 parent d5ab063 commit 25af2c2
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 82 deletions.
2 changes: 1 addition & 1 deletion cleaning_database_operations/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import models
from . import models
2 changes: 1 addition & 1 deletion cleaning_database_operations/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
"security/ir.model.access.csv",
"views/cleaning_database_view.xml",
],
'installable': True,
"installable": True,
}
148 changes: 88 additions & 60 deletions cleaning_database_operations/models/cleaning_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,120 +7,148 @@ class CleaningDatabase(models.Model):
_name = "cleaning.database"
_description = "Cleaning Database Operations"

name = fields.Char(
string="Description", copy=False)
name = fields.Char(string="Description", copy=False)
company_ids = fields.Many2many(
string="Companies", comodel_name="res.company",
relation='rel_cleaning_database_company',
column1='cleaning_database_id', column2='company_id',
required=True)
string="Companies",
comodel_name="res.company",
relation="rel_cleaning_database_company",
column1="cleaning_database_id",
column2="company_id",
required=True,
)

def action_delete_stock_operations(self):
self.env.cr.execute(
"DELETE FROM stock_move_line WHERE company_id in %s", [
tuple(self.company_ids.ids)])
"DELETE FROM stock_move_line WHERE company_id in %s",
[tuple(self.company_ids.ids)],
)
self.env.cr.execute(
"DELETE FROM stock_move WHERE company_id in %s", [
tuple(self.company_ids.ids)])
"DELETE FROM stock_move WHERE company_id in %s",
[tuple(self.company_ids.ids)],
)
self.env.cr.execute(
"DELETE FROM stock_picking WHERE company_id in %s", [
tuple(self.company_ids.ids)])
"DELETE FROM stock_picking WHERE company_id in %s",
[tuple(self.company_ids.ids)],
)
self.env.cr.execute(
"DELETE FROM stock_quant "
"WHERE company_id in %s OR lot_id in (select l.id "
" from stock_production_lot as l"
" where l.id = stock_quant.lot_id "
" and l.company_id in %s)", [
tuple(self.company_ids.ids), tuple(self.company_ids.ids)])
" and l.company_id in %s)",
[tuple(self.company_ids.ids), tuple(self.company_ids.ids)],
)
self.env.cr.execute(
"DELETE FROM stock_inventory WHERE company_id in %s", [
tuple(self.company_ids.ids)])
"DELETE FROM stock_inventory WHERE company_id in %s",
[tuple(self.company_ids.ids)],
)

def action_delete_stock_production_lot(self):
self.env.cr.execute(
"DELETE FROM stock_production_lot WHERE company_id in %s", [
tuple(self.company_ids.ids)])
"DELETE FROM stock_production_lot WHERE company_id in %s",
[tuple(self.company_ids.ids)],
)

def action_delete_stock_valuation_operations(self):
self.env.cr.execute(
"DELETE FROM stock_valuation_layer WHERE company_id in %s", [tuple(
self.company_ids.ids)])
"DELETE FROM stock_valuation_layer WHERE company_id in %s",
[tuple(self.company_ids.ids)],
)

def action_delete_sale_operations(self):
self.env.cr.execute(
"DELETE FROM sale_order_line WHERE company_id in %s", [
tuple(self.company_ids.ids)])
"DELETE FROM sale_order_line WHERE company_id in %s",
[tuple(self.company_ids.ids)],
)
self.env.cr.execute(
"DELETE FROM sale_order WHERE company_id in %s", [
tuple(self.company_ids.ids)])
"DELETE FROM sale_order WHERE company_id in %s",
[tuple(self.company_ids.ids)],
)

def action_delete_purchase_operations(self):
self.env.cr.execute(
"DELETE FROM purchase_order_line WHERE company_id in %s", [
tuple(self.company_ids.ids)])
"DELETE FROM purchase_order_line WHERE company_id in %s",
[tuple(self.company_ids.ids)],
)
self.env.cr.execute(
"DELETE FROM purchase_order WHERE company_id in %s", [
tuple(self.company_ids.ids)])
"DELETE FROM purchase_order WHERE company_id in %s",
[tuple(self.company_ids.ids)],
)

def action_delete_analytic_operations(self):
self.env.cr.execute(
"DELETE FROM account_analytic_line WHERE company_id in %s", [
tuple(self.company_ids.ids)])
"DELETE FROM account_analytic_line WHERE company_id in %s",
[tuple(self.company_ids.ids)],
)
self.env.cr.execute(
"DELETE FROM account_partial_reconcile WHERE company_id in %s", [
tuple(self.company_ids.ids)])
"DELETE FROM account_partial_reconcile WHERE company_id in %s",
[tuple(self.company_ids.ids)],
)
self.env.cr.execute(
"DELETE FROM account_payment_order WHERE company_id in %s", [
tuple(self.company_ids.ids)])
"DELETE FROM account_payment_order WHERE company_id in %s",
[tuple(self.company_ids.ids)],
)
self.env.cr.execute(
"DELETE FROM account_payment_line WHERE company_id in %s", [
tuple(self.company_ids.ids)])
"DELETE FROM account_payment_line WHERE company_id in %s",
[tuple(self.company_ids.ids)],
)
self.env.cr.execute(
"DELETE FROM account_move_line WHERE company_id in %s", [
tuple(self.company_ids.ids)])
"DELETE FROM account_move_line WHERE company_id in %s",
[tuple(self.company_ids.ids)],
)
self.env.cr.execute(
"DELETE FROM account_move WHERE company_id in %s", [
tuple(self.company_ids.ids)])
"DELETE FROM account_move WHERE company_id in %s",
[tuple(self.company_ids.ids)],
)
self.env.cr.execute(
"DELETE FROM account_bank_statement WHERE company_id in %s", [
tuple(self.company_ids.ids)])
"DELETE FROM account_bank_statement WHERE company_id in %s",
[tuple(self.company_ids.ids)],
)
self.env.cr.execute(
"DELETE FROM account_asset_line WHERE company_id in %s", [
tuple(self.company_ids.ids)])
"DELETE FROM account_asset_line WHERE company_id in %s",
[tuple(self.company_ids.ids)],
)
self.env.cr.execute(
"DELETE FROM account_asset WHERE company_id in %s", [
tuple(self.company_ids.ids)])
"DELETE FROM account_asset WHERE company_id in %s",
[tuple(self.company_ids.ids)],
)
self.env.cr.execute(
"DELETE FROM account_check_deposit WHERE company_id in %s", [
tuple(self.company_ids.ids)])
"DELETE FROM account_check_deposit WHERE company_id in %s",
[tuple(self.company_ids.ids)],
)

def action_delete_transport_operations(self):
self.env.cr.execute(
"DELETE FROM transport_carrier_lines_to_invoice WHERE company_id "
"in %s", [tuple(self.company_ids.ids)])
"DELETE FROM transport_carrier_lines_to_invoice WHERE company_id " "in %s",
[tuple(self.company_ids.ids)],
)

def action_delete_mrp_operations(self):
self.env.cr.execute(
"DELETE FROM mrp_workorder "
"WHERE production_id in (select p.id "
" from mrp_production as p "
" where p.id = mrp_workorder.production_id "
" and p.company_id in %s)", [
tuple(self.company_ids.ids)])
" and p.company_id in %s)",
[tuple(self.company_ids.ids)],
)
self.env.cr.execute(
"DELETE FROM mrp_production WHERE company_id in %s", [
tuple(self.company_ids.ids)])
"DELETE FROM mrp_production WHERE company_id in %s",
[tuple(self.company_ids.ids)],
)

def action_delete_sequance_operations(self):
sequences = self.env["ir.sequence"].search([
("number_next_actual", "!=", 1),
("company_id", "in", self.company_ids.ids)
])
sequences = self.env["ir.sequence"].search(
[
("number_next_actual", "!=", 1),
("company_id", "in", self.company_ids.ids),
]
)
for line in sequences:
line.number_next_actual = 1

@api.model
def create(self, values):
name = _(u"Creation date: {}".format(fields.Datetime.now()))
name = _("Creation date: {}".format(fields.Datetime.now()))
values["name"] = name
return super(CleaningDatabase, self).create(values)
return super().create(values)
106 changes: 86 additions & 20 deletions cleaning_database_operations/views/cleaning_database_view.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record model="ir.ui.view" id="cleaning_database_form_view">
Expand All @@ -11,7 +11,7 @@
<sheet>
<div class="oe_title">
<h1>
<field name="name" readonly="1"/>
<field name="name" readonly="1" />
</h1>
</div>
<group>
Expand All @@ -21,51 +21,108 @@
<p>Sales:</p>
<p>Sale Order Line, Sale Order.</p>
<p>
<button name="action_delete_sale_operations" type="object" string="Cleaning Sale Operations" class="oe_highlight"/>
<button
name="action_delete_sale_operations"
type="object"
string="Cleaning Sale Operations"
class="oe_highlight"
/>
</p>
<p>Purchases:</p>
<p>Purchase Order Line, Purchase Order.</p>
<p>
<button name="action_delete_purchase_operations" type="object" string="Cleaning Purchase Operations" class="oe_highlight"/>
<button
name="action_delete_purchase_operations"
type="object"
string="Cleaning Purchase Operations"
class="oe_highlight"
/>
</p>
<p>Accounting:</p>
<p>Account Analytic Line, Account Partial Reconcile, Account Move Line, Account Move, Account Payment Order.</p>
<p
>Account Analytic Line, Account Partial Reconcile, Account Move Line, Account Move, Account Payment Order.</p>
<p>
<button name="action_delete_analytic_operations" type="object" string="Cleaning Accounting Operations" class="oe_highlight"/>
<button
name="action_delete_analytic_operations"
type="object"
string="Cleaning Accounting Operations"
class="oe_highlight"
/>
</p>
<p>Manufacturing:</p>
<p>MRP Workorder, MRP Production</p>
<p>
<button name="action_delete_mrp_operations" type="object" string="Cleaning MRP Operations" class="oe_highlight"/>
<button
name="action_delete_mrp_operations"
type="object"
string="Cleaning MRP Operations"
class="oe_highlight"
/>
</p>
<p>Inventory:</p>
<p>Stock Move Line, Stock Move, Stock Picking, Stock Quant, Stock Valuation Layer, Stock Inventory, Stock Production Lot.</p>
<p
>Stock Move Line, Stock Move, Stock Picking, Stock Quant, Stock Valuation Layer, Stock Inventory, Stock Production Lot.</p>
<p>
<button name="action_delete_stock_valuation_operations" type="object" string="Cleaning Valuation Layers" class="oe_highlight"/>
<button
name="action_delete_stock_valuation_operations"
type="object"
string="Cleaning Valuation Layers"
class="oe_highlight"
/>
</p>
<p>
<button name="action_delete_stock_operations" type="object" string="Cleaning Stock Operations" class="oe_highlight"/>
<button
name="action_delete_stock_operations"
type="object"
string="Cleaning Stock Operations"
class="oe_highlight"
/>
</p>
<p>
<button name="action_delete_stock_production_lot" type="object" string="Cleaning Lots" class="oe_highlight"/>
<button
name="action_delete_stock_production_lot"
type="object"
string="Cleaning Lots"
class="oe_highlight"
/>
</p>
<p>Others</p>
<p>Transport Carrier Lines To Invoice</p>
<p>
<button name="action_delete_transport_operations" type="object" string="Cleaning Transport Operations" class="oe_highlight"/>
<button
name="action_delete_transport_operations"
type="object"
string="Cleaning Transport Operations"
class="oe_highlight"
/>
</p>
<p>Squence</p>
<p>Reset sequences</p>
<p>
<button name="action_delete_sequance_operations" type="object" string="Cleaning Sequences" class="oe_highlight"/>
<button
name="action_delete_sequance_operations"
type="object"
string="Cleaning Sequences"
class="oe_highlight"
/>
</p>
</div>
</group>
<group>
<separator string="Companies" colspan="4"/>
<field name="company_ids" nolabel="1" colspan="4" required="1">
<tree string="Companies" delete="0" create="0" editable="top">
<field name="name" readonly="1"/>
<separator string="Companies" colspan="4" />
<field
name="company_ids"
nolabel="1"
colspan="4"
required="1"
>
<tree
string="Companies"
delete="0"
create="0"
editable="top"
>
<field name="name" readonly="1" />
</tree>
</field>
</group>
Expand All @@ -92,8 +149,17 @@
<field name="view_mode">tree,form</field>
</record>

<menuitem name="Cleaning Database" id="cleaning_database" sequence="100" web_icon="cleaning_database_operations,static/description/boom_icon.png"/>
<menuitem
name="Cleaning Database"
id="cleaning_database"
sequence="100"
web_icon="cleaning_database_operations,static/description/boom_icon.png"
/>

<menuitem action="action_cleaning_database_view" id="menu_view_cleaning_database"
parent="cleaning_database" sequence="1"/>
<menuitem
action="action_cleaning_database_view"
id="menu_view_cleaning_database"
parent="cleaning_database"
sequence="1"
/>
</odoo>

0 comments on commit 25af2c2

Please sign in to comment.