Skip to content

Commit

Permalink
Merge pull request #216 from UniversalScientificTechnologies/dev_excl…
Browse files Browse the repository at this point in the history
…ude_from_bom

Implement exclusion from BOM list in case the exclude_from_bom property is set.
  • Loading branch information
roman-dvorak authored Nov 14, 2023
2 parents c2f9f20 + c4808f5 commit 46b1970
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 32 deletions.
53 changes: 27 additions & 26 deletions src/OpenIntranet/plugins/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def rounded_cell(self, w, h=0, txt='', border=0, ln=0, align='', fill=False, lin
style = 'FD'
elif fill:
style = 'F'
self.rounded_rect(self.get_x() + (cellspacing / 2.0),
self.rounded_rect(self.get_x() + (cellspacing / 2.0),
self.get_y() + (cellspacing / 2.0),
w - cellspacing, h, radius, corners, style)
self.cell(w, h + cellspacing, txt, 0, ln, align, False, link)
Expand All @@ -43,7 +43,7 @@ def rounded_rect(self, x, y, w, h, r, corners = (1,2,3,4), style = ''):
op='S'
my_arc = 4/3 * (math.sqrt(2) - 1)
self._out('%.2F %.2F m' % ((x+r)*k,(hp-y)*k ))
xc = x+w-r
xc = x+w-r
yc = y+r
self._out('%.2F %.2F l' % (xc*k,(hp-y)*k ))
if 2 not in corners:
Expand Down Expand Up @@ -81,7 +81,7 @@ def _arc(self, x1, y1, x2, y2, x3, y3):


class ComponentStatus(Enum):
Err = -1 # Nějaká chyba..
Err = -1 # Nějaká chyba..
Actual = 0 # polozka je nahrana z BOMu
Obsolete = 1 # Byl nahran novy BOM, ale polozka se v nem nevyskytuje
ModifiedManually = 2 # Polozka byla rucne upravena
Expand Down Expand Up @@ -151,7 +151,7 @@ def get_plugin_info():



## Projde seznam vsech komponent v pricelist, a zaktualizuje ceny komponent. Vyuzivaji se ceny posledniho nakupu.
## Projde seznam vsech komponent v pricelist, a zaktualizuje ceny komponent. Vyuzivaji se ceny posledniho nakupu.

def production_upadte_pricelist(db, production_id, price_work=-1, price_sell=-1, price_consumables=-1):
components = db.production.find_one({'_id': bson.ObjectId(production_id)}, {'pricing':1})
Expand Down Expand Up @@ -333,7 +333,7 @@ def post(self):
#pos['text'] = "{} <small>({})</small>".format(out['name'], out['description'])
#pos['text'] = "{} <small>({})</small>".format(out['name'], out['description'])
#pos['li_attr'] = {"name": out['name'], 'text': out['description']}

pos['parent'] = str(out.get('parent', '#'))
new.append(pos)

Expand Down Expand Up @@ -461,7 +461,7 @@ def post(self, group_id):
})

self.write("")


'''
Tabulka s BOMem pro zobrazeni v production
Expand All @@ -472,7 +472,7 @@ def get(self, name):

group_by_ustid = False
group_by_components = False

query = [
{'$match': {'_id': bson.ObjectId(name)}},
{'$unwind': '$components'},
Expand Down Expand Up @@ -507,7 +507,7 @@ def get(self, name):
"onError": "Err",
"onNull": "null"
}}}}]

query += [{"$lookup":{
"from": 'stock',
"localField": 'cUST_ID',
Expand All @@ -525,8 +525,8 @@ def get(self, name):
query += [
{"$sort": {'Ref':1}}
]


print(query)
dout = list(self.mdb.production.aggregate(query))
#out = bson.json_util.dumps(dout)
Expand All @@ -543,7 +543,7 @@ def get(self, name):

group_by_ustid = False
group_by_components = False

query = [
{'$match': {'_id': bson.ObjectId(name)}},
{'$unwind': '$components'},
Expand Down Expand Up @@ -578,7 +578,7 @@ def get(self, name):
"onError": "Err",
"onNull": "null"
}}}}]

query += [{"$lookup":{
"from": 'stock',
"localField": 'cUST_ID',
Expand All @@ -596,8 +596,8 @@ def get(self, name):
query += [
{"$sort": {'Ref':1}}
]


print(query)
dout = list(self.mdb.production.aggregate(query))
#out = bson.json_util.dumps(dout)
Expand All @@ -617,9 +617,9 @@ def get(self, name):


'''
EDitační stránka pro production
'''
class edit(BaseHandler):
def get(self, name):
Expand Down Expand Up @@ -943,7 +943,7 @@ def post(self, name):
flag=["reservation"]
)

# nastavit vyrobu na pripravenou
# nastavit vyrobu na pripravenou
self.mdb.production.update_one({"_id": bson.ObjectId(name)}, {"$set": {"state": 1, "multiplication": multiplication}})

# take zaktualizuj cenovy rozpis polozky
Expand Down Expand Up @@ -1060,14 +1060,14 @@ def post(self, name):
self.write(output)

'''
Ukoncit vyrobu a odecist soucastky ze skladu..
Ukoncit vyrobu a odecist soucastky ze skladu..
'''
class close_production(BaseHandler):
def get(self, name):
print("Přehled polozek pred ukoncenim, name")

product = self.mdb.production.aggregate([
{'$match': {'_id': bson.ObjectId(name)}},
{'$unset': 'components'}
Expand All @@ -1079,9 +1079,9 @@ def get(self, name):


'''
Vytvoř duplikat vyrobniho postupu a nech ho ve stejne slozce
'''
class duplicate(BaseHandler):
def get(self, name):
Expand Down Expand Up @@ -1129,6 +1129,7 @@ def make_comp_dict(self, element):
"Value": element.findall('value')[0].text,
"UST_ID": '',
"stock_count": None,
"exclude_from_bom": any(prop.find("name").text == "exclude_from_bom" for prop in element.findall("property")),
"status": ComponentStatus.Actual.value
}

Expand Down Expand Up @@ -1275,7 +1276,7 @@ def get(self, name):
"foreignField": '_id',
"as": 'packets'
}},
# {"$lookup":{ # tohle nefunguje jak by melo..
# {"$lookup":{ # tohle nefunguje jak by melo..
# "from": 'category_complete',
# "localField": 'components.stock.category',
# "foreignField": '_id',
Expand Down Expand Up @@ -1439,8 +1440,8 @@ def get(self, name):
pdf.set_line_width(0.1)
pdf.set_draw_color(110,110,110)
pdf.set_text_color(110,110,110)


for packet_i, packet in enumerate(packets.get('packets', [])):
packet_rount += 1

Expand Down
12 changes: 6 additions & 6 deletions src/OpenIntranet/templates/production.bom_table.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{%for i, row in enumerate(data) %}
{% set valid = bson.objectid.ObjectId.is_valid(row['cUST_ID']) %}


{% if not row.get("exclude_from_bom", False) %}
<tr>
<td>
<div>#{{i+1}}</div>
Expand Down Expand Up @@ -40,7 +42,7 @@
</td>

<td>

<div>
{%try%}
{% if not valid %}
Expand Down Expand Up @@ -75,14 +77,12 @@
{%end%}
{%end%}
{% except%}
ERROR...
ERROR...
{%end%}
</div>

</td>

</tr>



{% end %} <!-- Konec cele smycky for -->
{% endif %}
{% endfor %}

0 comments on commit 46b1970

Please sign in to comment.